Help with xpath

John Smith

Usenet Archive
Joined
May 5, 2000
Messages
1,003
Reaction score
0
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
 

John Smith

Usenet Archive
Joined
May 5, 2000
Messages
1,003
Reaction score
0
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
548,208
Messages
3,104,798
Members
249,594
Latest member
henrywalsh

Latest Threads

Top