Re: Problem evaluating XPath expression into a NodeList
Tod <[email protected]>
| Newsgroups | gmane.text.xml.xalan.java.user |
|---|---|
| Message-ID | <[email protected]> |
On 10/22/2009 3:07 PM, Tod wrote: > On 10/22/2009 8:39 AM, [email protected] wrote: >> > /default:feed/default:entry/default:summary/text() >> >> You're asking for text nodes. In the XPath view of the document, there >> is no such thing as an empty text node, so the empty elements have no >> children and do not contribute to this result. >> >> If you want to see them, search for the elements and then ask each one >> for its text content as a separate operation. >> >> ______________________________________ >> "... Three things see no end: A loop with exit code done wrong, >> A semaphore untested, And the change that comes along. ..." >> -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish ( >> http://www.ovff.org/pegasus/songs/threes-rev-11.html >> <http://www.ovff.org/pegasus/songs/threes-rev-11.html> ) > > > Thanks all for your help. I am now iterating through the results > returned by the XPath eval of > '/default:feed/default:entry/default:summary'. > > Could anybody suggest an elegant way to get these individual node values > back into a nodelist which my class is expected to return? > > Thanks again - Tod > Follow up... All I needed to do was to add a boolean to the XPath expression: /default:feed/default:entry/default:summary/text()|/default:feed/default:entry/default:summary[not(text())] This increases the size of the NodeList by the number of empty text nodes and solved my problem. - Tod