Help with xpath

J

John Smith

I am trying to query a documents

<level1>
<level2>
<level3>
x
<level4>a</level4>
<level4>b</level4>
<level4>c</level4>
</level3>
</level2>
</level1>

The Xpath query "/level1/level2/level3[level4/text()='b']" find b, but
"/level1/level2[level3/text()='x']" finds nothing as does "//*[text()='x']"
..

Why is this?

Many Thanks

Jon
 
J

John Smith

A bit futher on now, it appears the "x" text node has a newline character in
it. Altering the query to
"/level1/level2[level3/normalize-space(text())='x']" works. Altering the
document to:

<level1>
<level2>
<level3>
x<level4>a</level4>
<level4>b</level4>
<level4>c</level4>
</level3>
</level2>
</level1>

also works, I am using a java dom parser with the XpathAPI to do the search.
An ideas?

Many Thanks

Jon
 

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,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top