Cannot find JDOM node through xpath after clone



I have a xml document, and I use JDOM to parse it and use XPATH API provided by JDOM to find some element, it works well.


Example: <person> <info name="gg" age="0" hobby="hi" /> </person>


Through API:



XPath.selectSingleNode(baseElement,"//*[local-name()='info");


I can get the correct info.


Then I try to clone a new baseElement with baseElement.clone().


After that, if I try:



XPath.selectSingleNode(baseElementClone,"//*[local-name()='info");


I got nothing.


The only diff I can image is that after clone, it will lose the parent info. But I dont why it will affect the search result.


Pls let me know if you think the question is unclear.


BTW, my JDOM version is 1.0


Br, Tim


No comments:

Post a Comment