Bugs item #1116471, was opened at 2005-02-04 13:06 Message generated for change (Comment added) made by nobody 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. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2005-02-10 09:49 Message: Logged In: NO This problem affects other xpath query types sch as /a/b/* etc... ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116035&aid=1116471&group_id=16035 ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ dom4j-dev mailing list dom4j-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-dev