| Author |
XpathAPI utility class of Crimson parser.
|
Rahul Bhattacharjee
Ranch Hand
Joined: Nov 29, 2005
Posts: 2300
|
|
Is the crimson's xpath utility (XpathAPI) fully compatible to the xPath standards.I have tried some xpaths on a dom , but did not get expected results.I have following strict Xpath rults , this made me feel that this api mught not be following xPath strictly. XML under consideration: <?xml version="1.0" encoding="UTF-8"?> <father age="70"> <son> <age>29</age> </son> <son name="Kumar"> <age>22</age> </son> </father> and Xpath /father/son[1]/@name/text() should return Kumar but I am getting nothing. Why is that so ?
|
Rahul Bhattacharjee
LinkedIn - Blog
|
 |
Prabhu Venkatachalam
Ranch Hand
Joined: Nov 16, 2005
Posts: 502
|
|
Rahul, It seems like XPATH is wrong. Try this " /father/son[2]/@name ". Let me know if this didn't work.
|
Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
|
 |
Rahul Bhattacharjee
Ranch Hand
Joined: Nov 29, 2005
Posts: 2300
|
|
Originally posted by Prabhu venkatachalam: It seems like XPATH is wrong. Try this " /father/son[2]/@name ". Let me know if this didn't work.
Yes Prabhu , this is working and returning me Kumar. My xpath was worng. /text() is not supposed to be used with attributes (only to be used with elements.). Thanks,
|
 |
Prabhu Venkatachalam
Ranch Hand
Joined: Nov 16, 2005
Posts: 502
|
|
you are correct. text() XPATH function should be use with element to findout its text value. Thanks!
|
 |
 |
|
|
subject: XpathAPI utility class of Crimson parser.
|
|
|