[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: How to display content of a collection list (XML) in separ

  • From: "Michael Kay" <mike@s...>
  • To: "'Jack Bush'" <netbeansfan@y...>,<xml-dev@l...>
  • Date: Tue, 7 Oct 2008 21:30:59 +0100

RE:  How to display content of a collection list (XML) in separ
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/


From: Jack Bush [mailto:netbeansfan@y...]
Sent: 07 October 2008 21:21
To: xml-dev@l...
Subject: 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. 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]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.