Read XML configuration file

Hi,my application has to read the configuration from a XML configuration file. It's once as it starts, and it is not read or written after that.Which is the best way to implement it?Thanks
[217 byte] By [txatia] at [2007-11-27 5:42:23]
# 1
That depends on what kind of application it is. If it's a plain old Java application, read the XML file in your startup code.
DrClapa at 2007-7-12 15:20:58 > top of Java-index,Java Essentials,Java Programming...
# 2

Sorry, I think that I didn't explain myself very well.

I was trying to mean, which API shoould I use? JAXP is ok?

It's been a long time since I used it, and I don't know if there is a better or newer API. Third part or whatever.

As I wrote, it's just for reading a config file.

Thanks again!

txatia at 2007-7-12 15:20:58 > top of Java-index,Java Essentials,Java Programming...
# 3
Get [url= http://jakarta.apache.org/commons/digester/]Apache Digester[/url]. Designed exactly for this
georgemca at 2007-7-12 15:20:58 > top of Java-index,Java Essentials,Java Programming...
# 4

Finally I'll use JAXP and SAX to read my application XML config file.

But I'm lost.

How does it function, do I have to put in the startElement() method as many "if" as entitys I need to process?

Example:

<program>

<printer id="xx" type="aa"/>

<source path="/aa/bb">

</program>

for this XML, how would you do? this way?

startElement (String uri, String localName, String qName, Attributes attributes) {

if (localname.equals("printer")) {

//get printer attributes

} else if (localname.equals("source")) {

//get source attributes

}

}

Thanks

txatia at 2007-7-12 15:20:58 > top of Java-index,Java Essentials,Java Programming...