XSLT: How to find a node containing TWO matching children?

Discussion in 'XML' started by bearclaws, Mar 10, 2005.

  1. bearclaws

    bearclaws Guest

    I have the following XML:

    <AAA>
    <BBB>
    <CCC>111</CCC>
    <CCC>222</CCC>
    </BBB>
    <BBB>
    <CCC>333</CCC>
    <CCC>444</CCC>
    </BBB>
    </AAA>

    ....and want to loop through AAA to find all BBBs that contain CCC nodes
    matching 333 AND 444.

    Any thoughts on the most effecient syntax for this?

    Thanks,
    BC
    bearclaws, Mar 10, 2005
    #1
    1. Advertising

  2. bearclaws

    Joris Gillis Guest

    Tempore 18:40:18, die Thursday 10 March 2005 AD, hinc in foro {comp.text.xml} scripsit bearclaws <>:

    > ...and want to loop through AAA to find all BBBs that contain CCC nodes
    > matching 333 AND 444.
    >

    what about "AAA/BBB[CCC='333' and CCC='444']" ?


    regards,
    --
    Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
    "Quot capita, tot sententiae" - Terentius , Phormio 454
    Joris Gillis, Mar 10, 2005
    #2
    1. Advertising

  3. bearclaws wrote:

    > I have the following XML:
    >
    > <AAA>
    > <BBB>
    > <CCC>111</CCC>
    > <CCC>222</CCC>
    > </BBB>
    > <BBB>
    > <CCC>333</CCC>
    > <CCC>444</CCC>
    > </BBB>
    > </AAA>
    >
    > ...and want to loop through AAA to find all BBBs that contain CCC nodes
    > matching 333 AND 444.


    If <AAA> is the root element there is not much to loop through, as for
    an XPath you would need
    /AAA/BBB[CCC = '333' and CCC = '444']

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Mar 10, 2005
    #3
  4. bearclaws

    bearclaws Guest

    thanks! I was making my statement *much* more complicated than it
    needed to be!

    >>BC
    bearclaws, Mar 10, 2005
    #4
    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,816
    Michael Reiche
    Feb 5, 2004
  2. Replies:
    18
    Views:
    2,739
    Joseph Kesselman
    Oct 4, 2006
  3. clover2411
    Replies:
    4
    Views:
    943
    Andy Dingley
    Jan 23, 2007
  4. Replies:
    1
    Views:
    470
    Martin Honnen
    May 16, 2007
  5. Zachary  Turner
    Replies:
    1
    Views:
    514
    Bjoern Hoehrmann
    May 30, 2007
Loading...

Share This Page