Your first xpath '/*/person' returns all person elements.

Note: Starting an XPath expression with '/' will disregard the current
context and will start evaluating the expression from the root
element.

So your second xpath '/*/name/text()' would have returned a value if
your document had the following structure:

<db>
  <name>Jack</name>
  <name>Barbara</name>
</db>
 
To fix this use a relative XPath expression: 'name/text()'

String name(Element e) {
   XPath nameXPath = DocumentHelper.createXPath("name/text()");
   return nameXPath.valueOf(e); // valueInside() would have been a nicer name
}

Regards,
Edwin


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to