xpath expression

Discussion in 'XML' started by ricky, May 17, 2004.

  1. ricky

    ricky Guest

    I need to retrieve all nodes that have one child and this child must be a node text.

    For example:

    <x>
    <y>1</y>
    <w><g></g></w>
    <z></z>
    </x>

    must return:

    The node-set: y,g,z

    thanks in advance

    Ricky
    ricky, May 17, 2004
    #1
    1. Advertising

  2. ricky wrote:
    > I need to retrieve all nodes that have one child and this child must be a node text.
    >
    > For example:
    >
    > <x>
    > <y>1</y>
    > <w><g></g></w>
    > <z></z>
    > </x>
    >
    > must return:
    >
    > The node-set: y,g,z


    g and z don't have any child nodes and should not be returned by your
    definition above.
    --
    Johannes Koch
    In te domine speravi; non confundar in aeternum.
    (Te Deum, 4th cent.)
    Johannes Koch, May 17, 2004
    #2
    1. Advertising

  3. In article <>,
    ricky <> wrote:
    % I need to retrieve all nodes that have one child and this child must be
    % a node text.

    You could try *[count(*) = 0][count(text()) = 1]

    This returns only y in your example, but that's because g and z
    don't have any text in them (<z></z> is the same as <z/>)

    --

    Patrick TJ McPhee
    East York Canada
    Patrick TJ McPhee, May 18, 2004
    #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. Marvin_123456

    "Memory leak" in javax.xml.xpath.XPath

    Marvin_123456, Jul 29, 2005, in forum: Java
    Replies:
    4
    Views:
    1,942
    jan V
    Jul 29, 2005
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,359
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. Anna
    Replies:
    0
    Views:
    501
  4. goog
    Replies:
    0
    Views:
    488
  5. GIMME
    Replies:
    3
    Views:
    11,909
    vforvikash
    Dec 29, 2008
Loading...

Share This Page