David,
you can make relative queries by prefixing your xpath query with ".",
e.g. myElement.selectNodes("./mysubelement/mysub").
As an example:
for (Iterator iter = doc.selectNodes("/a/b").iterator; iter.hasNext();) {
Element elem = (Element) iter.next();
for (Iterator iter2 = eleme.selectNodes("./c/d").iterator;
iter2.hasNext();) {
Element elem2 = (Element) iter.next();
System.out.println("name: " + elem2.attributeValue("name");
}
}
Hope this helps, Silvain
----- Original Message -----
From: David Thielen
To: [EMAIL PROTECTED]
Sent: Thursday, February 14, 2002 0:52
Subject: [dom4j-user] selectNodes inside selectNodes - relative xpath?
Hi;
First off, thanks for the help on the previous question - it was very much
appreciated.
So here is question two.
I do a selectNodes ( "xpath" ) and get a list.
While I am iterating through that list, I do a selectNodes ( "xpath2" ) and
get a second list I am iterating through.
While iterating through these lists I want to do relative xpaths (including
possibly for the xpath2 on the second selectNodes).
Here's my question - when I have finished iterating through the xpath2
items, I am still in the original xpath iteration - how do I go back to
doing relative paths off the outer iteration?
And how do I do relative paths off the outer iteration while inside the
inner iteration?
thanks - dave
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user