xpath expression

R

ricky

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
 
J

Johannes Koch

ricky said:
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.
 
P

Patrick TJ McPhee

% 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/>)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top