Results 1 to 2 of 2

Thread: XPath - Return current node without child nodes

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Posts
    101

    Talking XPath - Return current node without child nodes

    Good day.

    I hv the following XML for example and I tried to write a XPath query to return just the <AAA> and omit all the other child nodes (BBB and CCC and BBBBB) .

    <AAA Name='aaa' ID='aaa'>
    <BBB>bbbbbbbbbb</BBB>
    <BBBBB>bbbbbbbbbbbbbbb</BBBBB>
    <CCC>cccccccccc</CCC>
    </AAA>

    I tried //AAA/self::* but it still return the whole childnodes to me.

    Any idea how to accomplish this ?

    Thanks.

    SonicWave

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: XPath - Return current node without child nodes

    I suppose XPath returns the AAA node, which has all other nodes as descendants, right? I cannot imagine that it returns a NodeSet that directly contains all the nodes.

    Well, that's something you can't change with XPath. XPath only returns references to nodes, it can't change them. Returning a reference means that in order to have no child nodes, it must either return a copy or modify the referenced node. Neither makes sense.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width