XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
How to display content of a collection list (XML) in separate line

Hi All,

I would like to display the content of a collection list into individual line (which was captured from the following XML tree) to one continuous line.

<p>    // p[11]
<strong>Near by Parks:</strong> 
<br /> 
Capital Hill Park (1.2km away) 
<br /> 
Centenial Park (3.4km away) 
<br /> 
Robertson Park (5.2km away) 
<br /> 
.......
</p>


Below is the snippets that have successfully parsed these contents into a collection list using JDOM:

( 1 )  java.util.List near_by_parks = XPath.selectNodes(jdomDocument, "/html/body/div[@id='container']/div[@id='content']/p[11]" );
( 2 )  Iterator near_by_parks_iterator = near_by_parks.iterator();
( 3 )  while (near_by_parks_iterator.hasNext())
( 4 )  {
( 5 )       System.out.println("Near by parks: " + ((org.jdom.Element)near_by_parks_iterator.next()).getTextNormalize());
( 6 )  }
 
Output from this code is:
 
Near by parks: Capital Hill Park (1.2km away)Centenial Park (3.4km away)Robertson Park (5.2km away)...
 
However, I would like the following output instead in order to assign them into different variables:
 
Near by parks: Capital Hill Park (1.2km away)
Near by parks: Centenial Park (3.4km away)
Near by parks: Robertson Park (5.2km away)
......
It appears that it the ArrayList had incorrectly pick up all the contents (incorrect XPath statement) in the first place.

Your advice would be much appreciated.

Thanks,

Jack


Make the switch to the world's best email. Get Yahoo!7 Mail.

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS