[Home] [By Thread] [By Date] [Recent Entries]
Hi Michael,
Thanks for responding back to this question. The following changes have been made to overcome this issue:
( i ) XPath.selectNodes(jdomDocument, "/html/body/div[@id='container']/div[@id='content']/p[11]/node()" ); ( ii ) System.out.println(((org.jdom.Content)nearest_hotels_iterator.next()).getValue());
Below is the output from these change:
Nearest Parks: Capital Hill (1.2km away)
Centenial Park (3.4km away)
Robertson Park (5.2km away)
I have been able to alleviate those blank newlines (possibly from <br />) with additional checks for no blank line prior to printing them out. Nevertheless, I am wondering whether there is a better way to do this in JDOM instead. In other word, I would like to get the following output: Nearest Parks: Capital Hill (1.2km away) Centenial Park (3.4km away) Robertson Park (5.2km away)
Apart from this minor cosmetic preference, this solution is working fine. Thanks again, Jack ----- Original Message ---- From: Michael Kay <mike@s...> To: Jack Bush <netbeansfan@y...>; xml-dev@l... Sent: Wednesday, 8 October, 2008 7:30:59 AM Subject: RE: How to display content of a collection list (XML) in separate line You want to iterate over the children of the p element (so it's "..../p[11]/node()"), and for each node you process, if it's a <br/> element then output a newline, otherwise output its string value.
Michael Kay
http://www.saxonica.com/
Make the switch to the world's best email. http://au.rd.yahoo.com/mail/taglines/au/mail/default/*http://au.yahoo.com/y7mail.
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] |

Cart



