f



Read XML file from Java

Hi,
I'm trying to read the contents of an XMl file from my Java class.

Sample: 
====================================================

<tag name="First" >
   <Line> One </Line> 
   <Line> Two </Line>
</tag>

<tag name ="Second" >
   <Line> Three </Line> 
   <Line> Four </Line>
</tag>	
====================================================

I want to extract info from the tags and after some parsing, display
them as:

From first tag: This is processed info. on lines One, Two
From second tag: This is processed info. on lines Three, Four

As you can see, I dont want anything fancy, just some ability to
specify a file and some specific tags that
I'm interested in and be able to extract info b/w those tags.

1) Is this possible with SAX, I dont see examples dealing with
"specify tags and get info."
2) I maynot be in a position to install the sax jars, are there any
easy ways to do this without SAX?

Thanks,
Prab
0
Prab_kar (54)
11/5/2003 2:28:34 PM
comp.lang.java.help 13339 articles. 0 followers. Post Follow

1 Replies
488 Views

Similar Articles

[PageSpeed] 8

On 5 Nov 2003 06:28:34 -0800, Prab_kar@hotmail.com (Prabh) wrote:

>1) Is this possible with SAX, I dont see examples dealing with
>"specify tags and get info."

Sounds like you want to use DOM. SAX is more of an event driven
method, where you write methods that get called when certain events
happen.


>2) I maynot be in a position to install the sax jars, are there any
>easy ways to do this without SAX?

I believe the most recent versions of the JDK come with the libraries
you need.
0
spamtrap11 (620)
11/5/2003 5:25:43 PM
Reply: