Bugs item #1116471, was opened at 2005-02-04 21:06 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=1116471&group_id=16035
Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Steve Carter (cart33) Assigned to: Nobody/Anonymous (nobody) Summary: Problem with XPath and retrieving text Initial Comment: I have a Junit test similar to the following: public void test() { fiinal String XML = "<a><b>Water T & D-46816</b></a>"; final String XPATH = "a/b/text()"; final String EXPECTED_VALUE = "Water T & D-46816"; XPath xpathObj = createXpathObject(XPATH ); Document doc = createDocument(XML ); Object node = xpathObj.selectSingleNode(doc); if (node instanceof Text) { result = ((Text) node).getText(); } assertEquals(EXPECTED_VALUE, result)); } which fails because getText() only returns: Water T interrogating the node object returned from selectSingleNode indicates that the expected result is present as 3 seperate text elements in the content (ArrayList) member variable I can retrieve the value if I tweak the approach to use: final String XPATH = "a/b"; if (node instanceof Element) { return (String) ((Element) node).getData(); } If i dont have entity references then the first approach always works. Therefore this seems to be a bug, please correct me if i am wrong. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116035&aid=1116471&group_id=16035 ------------------------------------------------------- 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-dev mailing list dom4j-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-dev