select nodes with child node A and child node B

Discussion in 'XML' started by gplott@yahoo.com, Nov 1, 2006.

  1. Guest

    I have an XML document that has multiple childe nodes like the one at
    the end of this message

    What syntax would I use with selectNodes to select all viewentry nodes
    that have an

    entrydata child node with a name attribute equal to
    "CourseOrMeetingName"
    that has a text childe node with the text Course ABC

    AND that also have an

    entrydata child with a name attribute equal to Start Date
    that has a datetime child node with the text 20070110

    I was trying something like

    //viewentry[ (entrydata[@name='CourseOrMeetingName'][text='Course
    ABC']) and (entrydata[@name='StartDate'][datetime='20070110'])]"

    <viewentry position="1" unid="E5FE575692CAB4CD852572140052F751"
    noteid="893A" siblings="24">
    <entrydata columnnumber="0" name="CourseOrMeetingName">
    <text>Course ABC</text></entrydata>
    <entrydata columnnumber="1" name="StartDate">
    <datetime>20070110</datetime></entrydata>
    <entrydata columnnumber="2" name="City">
    <text>West chester</text></entrydata>
    <entrydata columnnumber="3" name="FirstName">
    <text>Joe</text></entrydata>
    <entrydata columnnumber="4" name="MiddleName">
    <text></text></entrydata>
    <entrydata columnnumber="5" name="LastName">
    <text>Blow</text></entrydata>
    </viewentry>

    Thanks,

    Glenn
     
    , Nov 1, 2006
    #1
    1. Advertising

  2. wrote:
    > //viewentry[ (entrydata[@name='CourseOrMeetingName'][text='Course
    > ABC']) and (entrydata[@name='StartDate'][datetime='20070110'])]"


    Works just fine when I try it on your sample fragment, using Xalan:

    <?xml version='1.0'?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <xsl:copy-of select="//viewentry[
    (entrydata[@name='CourseOrMeetingName'][text='Course ABC']) and
    (entrydata[@name='StartDate'][datetime='20070110'])]"/>
    </xsl:template>
    </xsl:stylesheet>

    Output is
    <?xml version="1.0" encoding="UTF-8"?><viewentry position="1"
    unid="E5FE575692CAB4CD852572140052F751" noteid="893A" siblings="24">
    <entrydata columnnumber="0" name="CourseOrMeetingName">
    <text>Course ABC</text></entrydata>
    <entrydata columnnumber="1" name="StartDate">
    <datetime>20070110</datetime></entrydata>
    <entrydata columnnumber="2" name="City">
    <text>West chester</text></entrydata>
    <entrydata columnnumber="3" name="FirstName">
    <text>Joe</text></entrydata>
    <entrydata columnnumber="4" name="MiddleName">
    <text/></entrydata>
    <entrydata columnnumber="5" name="LastName">
    <text>Blow</text></entrydata>
    </viewentry>

    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
     
    Joe Kesselman, Nov 1, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael Reiche
    Replies:
    3
    Views:
    10,853
    Michael Reiche
    Feb 5, 2004
  2. Bryan Ax
    Replies:
    6
    Views:
    547
    Peter Flynn
    May 17, 2006
  3. Replies:
    1
    Views:
    574
    Soren Kuula
    Aug 24, 2006
  4. Luqman
    Replies:
    2
    Views:
    879
    Luqman
    Jun 5, 2007
  5. William  Krick
    Replies:
    4
    Views:
    14,357
    anntenna
    Mar 18, 2011
Loading...

Share This Page