• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

questions on XML

 
kira yamato
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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 ?
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try using Jakarta Commons Digester.
 
kira yamato
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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>
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic