xpath expression

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ricky

    #1

    xpath expression

    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
  • Johannes Koch

    #2
    Re: xpath expression

    ricky wrote:[color=blue]
    > 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[/color]

    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.)

    Comment

    • Patrick TJ McPhee

      #3
      Re: xpath expression

      In article <df26e403.04051 70145.5e4c3c2a@ posting.google. com>,
      ricky <ricardo.queiro s@mail.pt> 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
      ptjm@interlog.c om

      Comment

      Working...