• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

questions on XML

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So sorry..i was a newbie in doing XML right now.

i have an xml file which is like this

<?xml version='1.0' encoding='UTF-8'?>

<navigation>
<links>http:www.yahoo.com.sg</links>
<links>http:www.yahoo.com.sg 1</links>
<links>http:www.yahoo.com.sg 2</links>
<links>http:www.yahoo.com.sg 3</links>
<links>http:www.yahoo.com.sg 4</links>
</navigation>

my question is how do i get all the values encapsulated in between <link></links> tag for my j2ee project ?
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could try using Jakarta Commons Digester.
 
kira yamato
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh..ok..i tried common digester...
but i'm not sure how it works..when i looked at the user guide..it seems confusing

so..is there anyone who can explain an example on how to do it ??of course in layman terms..

for example this xml file

<?xml version='1.0' encoding='UTF-8'?>

<navigation>
<links>http:www.yahoo.com.sg</links>
<links>http:www.yahoo.com.sg 1</links>
<links>http:www.yahoo.com.sg 2</links>
<links>http:www.yahoo.com.sg 3</links>
<links>http:www.yahoo.com.sg 4</links>
</navigation>

regarding read the values in between <links></links>
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the short answer is -

You need to parse the XML file. Using either the SAX or the DOM API's.
Once you parse the file and get the document object in DOM or implement the Start, Charecters and End element messages in SAX, you will be able to acheive what you are looking for.

A starting point would be some tutorial and example code.

- m
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic