I'm having some odd difficulties using dom4j to process XPath statements on my documents. I've been working through the quick start, and have browsed the mailing list, so I hope I'm not overlooking something, or doing something really dumb...

I retrieve my XML from an XML database (XStreamDB), and successfully feed it to dom4j to get back an Element (or a Document) representing the contents of the xml document.

Now, I'm trying to use dom4j to process the contents of the Document to pull out some values (and to insert/change some values).

I'm doing something like this (I've simplified the XPath to show something that should have at least one value in my document):


String xmlContent = (some magical process to get it from the database)
Document myDocument = reader.read( new InputSource( new StringReader( xmlContent ) ) ).getDocument();
XPath xpath = DocumentHelper.createXPath( "//identifier" );
Node identifierNode = xpath.selectSingleNode( myDocument );
List matchingNodes = xpath.selectNodes( myDocument );
System.out.println( identifierNode );
System.out.println( matchingNodes );


All I get for identifierNode is null, and matchingNodes is an empty List.

My documents have at least one "identifier" element, so I'm confused why dom4j isn't finding either.

If I open up the xpath selector to be something like "//string" (there are dozens of "string" elements in each document), I still get null for the selectSingleNode(), and an empty List for selectNodes().

Any ideas, tips or hints would be greatly appreciated!


- D'Arcy Norman Software Developer Learning Commons, The University of Calgary [EMAIL PROTECTED] http://careo.ucalgary.ca http://commons.ucalgary.ca/weblogs/dnorman (403) 220-2504 AIM/iChatAV: [EMAIL PROTECTED]



-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to