Maarten is correct, without the Document you'll get a null pointer exception from XPath.

--Mike

Maarten Coene wrote:
Hi Andreas,
 
if I remember correctly (I don't have access to the sources from here), the nodes have to be part of a document if you execute an XPath query on them.
 
hope this helps
 
Maarten

Andreas Brillisauer <[EMAIL PROTECTED]> wrote:




Hello,

I have parsed an OpenOffice.org document (content.xml) and tried to get a
list of all "table:table" elements. Therefore I used the following code.

Document doc = reader.read(myFile);
List list1 = doc.selectNodes("//table:table");
Element body =
(Element)doc.selectSingleNode("/office:document-content/office:body").detach();
List list2 = body.selectNodes("//table:table");

The first call of selectNodes works fine. list1 contains all "table:table"
elements. But when I detach the "office:body" element (is a child of the
root element) and call the selectNodes from body I always get an empty
list. But all "table:table" elements are descendants of "office:body". So
the result should be the same.

Does selectNodes work correctly only on nodes that are part of an existing
document and not on nodes that are d etached from an document? That's the
only difference I can see.

Kind regards,
Andreas



-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user


Do you Yahoo!?
The all-new My Yahoo! – Get yours free!

------------------------------------------------------- This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8 _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to