U
uros
<People>
<Employ> John Denver </Employ>
...A subtree....
<Employ> Mike Harris> </Employ>
....Another subtree....
<Employ> Mark White </Employ>
.....More subtree....
</People>
In the case of this structure the next method will return the Employ
node. The subtree then can be found as children nodes.
public Node findNodeWithValue(Node ancestor,String testValue)throws
Exception{
NodeList list=XPathAPI.selectNodeList(ancestor,"//People/Employ/text()");
for(int i=0;i<list.getLength();i++){
if(textValue.equal(list.getItem(i).getNodeValue()))return
list.getItem(i);
}
return null;
}
<Employ> John Denver </Employ>
...A subtree....
<Employ> Mike Harris> </Employ>
....Another subtree....
<Employ> Mark White </Employ>
.....More subtree....
</People>
In the case of this structure the next method will return the Employ
node. The subtree then can be found as children nodes.
public Node findNodeWithValue(Node ancestor,String testValue)throws
Exception{
NodeList list=XPathAPI.selectNodeList(ancestor,"//People/Employ/text()");
for(int i=0;i<list.getLength();i++){
if(textValue.equal(list.getItem(i).getNodeValue()))return
list.getItem(i);
}
return null;
}