Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can I do XPath subqueries from a NodeList object, using javax.xml.* ?

843834Jan 13 2009 — edited Jan 13 2009
Hello,

I need to read a huge XML document, so I've been trying to get several smaller parts to search into.

As a first step, I've created a Document object, under the javax.xml.xpath.* and javax.xml.parsers.* model:
            
            domFactory = DocumentBuilderFactory.newInstance();
            builder = domFactory.newDocumentBuilder();
            doc = builder.parse(new File(inXML));
            xpath = XPathFactory.newInstance().newXPath();
Later, I used a first evaluate to get a NodeList (my subset of the original Document):
            NodeList de = (NodeList) xpath.evaluate("//sampleLabel/smallPart", doc, XPathConstants.NODESET);
And I would like to search into the de NodeList, like this:
            NodeList subSet = (NodeList) xpath.evaluate("//firstElementofSet/text()", de, XPathConstants.NODESET);
However, I've got a "javax.xml.transform.TransformerException" (Unknown Xpath Error)

What am I doing wrong?

For your support, thank you in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 10 2009
Added on Jan 13 2009
2 comments
524 views