Finding elements without specific descendants

Discussion in 'XML' started by mwebb415@yahoo.com, Jul 24, 2007.

  1. Guest

    I'm trying to take a large XML file and identify a subset of nodes.
    The XML has a structure similar to:

    <root>
    <home>
    <test>junk</test>
    </home>
    <home>
    <xxx>Hi There!</xxx>
    <aaa>No value add</aaa>
    <test>More testing</test>
    <bbb>More nothing</bbb>
    </home>
    .
    .
    .
    .
    .
    </root>

    What I'd like to do is find <home> nodes that do not have the <aaa>,
    <xxx> or <bbb> child elements. The source file has approximately 500
    nodes in total, and I expect that the number of those that are missing
    all three of the child elements to be in the single digits, but I have
    to account for them. I'm generating a large XPath query and parsing
    the file on the fly via PHP.

    Any thoughts? Is this possible?

    Thank you!
     
    , Jul 24, 2007
    #1
    1. Advertising

  2. Joseph Kesselman, Jul 24, 2007
    #2
    1. Advertising

  3. Guest

    On Jul 24, 2:42 pm, Joseph Kesselman <>
    wrote:
    > wrote:
    > > What I'd like to do is find <home> nodes that do not have the <aaa>,
    > > <xxx> or <bbb> child elements.

    >
    > /root/home[not(aaa) and not(bbb) and not(xxx)]
    >
    > http://www.w3.org/TR/xpath#predicateshttp://www.w3.org/TR/xpath#booleans
    >
    > --
    > Joe Kesselman / Beware the fury of a patient man. -- John Dryden


    Thanks - that did it! Thought I was missing something very obvious.
    Much appreciated!
     
    , Jul 25, 2007
    #3
    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. Replies:
    1
    Views:
    403
    Joseph Kesselman
    Oct 27, 2006
  2. mazdotnet
    Replies:
    2
    Views:
    419
    Alexey Smirnov
    Oct 2, 2009
  3. Jason Lillywhite

    Class#descendants?

    Jason Lillywhite, Aug 12, 2009, in forum: Ruby
    Replies:
    17
    Views:
    195
    Duck Typist
    Sep 3, 2009
  4. Rainer Kugeland

    Finding all elements on specific coordinates

    Rainer Kugeland, Jul 21, 2003, in forum: Javascript
    Replies:
    2
    Views:
    121
    Rainer Kugeland
    Jul 23, 2003
  5. Tom de Neef

    How to create descendants of Array class?

    Tom de Neef, Mar 17, 2008, in forum: Javascript
    Replies:
    7
    Views:
    144
    Richard Cornford
    Mar 24, 2008
Loading...

Share This Page