Bugs item #1745280, was opened at 2007-06-29 11:52
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=1745280&group_id=16035
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: ntalamai (ntalamai)
Assigned to: Nobody/Anonymous (nobody)
Summary: selectSingleNode(String) searches from parent node
Initial Comment:
I don't know if this is a deliberate feature or if it is poorly documented in
the javadoc, but assume you have selected a non-parent element in an XML
Document. Doing selectNode(...) on this element will start looking for the
XPath expression from the root of the document. Consider the following simple
example:
<?xml version="1.0" encoding="UTF-8"?>
<repository last-edited="Mon Jun 25 17:34:48 BST 2007">
<atomic>
<name>atom01</name>
<compUnit>computationUnits.Calculator</compUnit>
</atomic>
<atomic>
<name>atom02</name>
<compUnit>computationUnits.Calculator</compUnit>
</atomic>
</repository>
SAXReader reader = new SAXReader();
Element root = reader.read(new File(fileName))
.getRootElement();
for(Object o: root.elements()){
Element e = (Element) o;
Node n = e.selectSingleNode("//name");
}
Node n will always be <name>atom01</name>, even when the currently selected
element is the 2nd <atomic> with <name> atom02. In fact the call
e.selectSingleNode("/repository/atomic/name") is always possiblem, while calling
e.selectSingleNode("/atomic/name") returns null.
If this is a deliberate behaviour, it should have been stated clearly in the
javadoc.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=1745280&group_id=16035
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
dom4j-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev