File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes XML vs Properties file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML vs Properties file" Watch "XML vs Properties file" New topic
Author

XML vs Properties file

Suresh Sankar
Greenhorn

Joined: May 25, 2005
Posts: 14
hi all,
which one is good(in performance).for dynamic configuration of application
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41096
    
  44
Assuming the config information doesn't change during the runtime of the application, performance should not be a major factor in deciding between the two. It's likely that startup and configuration time pale in comparison to the overall execution time of the application.


Ping & DNS - my free Android networking tools app
Suresh Sankar
Greenhorn

Joined: May 25, 2005
Posts: 14
i mean which one is advanced and flexible
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
I would only go with a properties approach IF:
1. All parameters can be represented as simple name - value pairs
2. There is absolutely no hierarchy or other structure that controls the use of the name - value pairs.

Dynamic configuration (which I take to mean changing the configuration of a running program) can be done with either approach. Just make sure that synchronization is used to prevent access during the changeover, and that changes properly propagate through the system.

I use XML where my applications have to support a fairly deep hierarchy and properties for simple stuff.
Bill
[ July 05, 2005: Message edited by: William Brogden ]
S Hussain
Greenhorn

Joined: Jul 07, 2005
Posts: 5
Well... heirarchy in XML is imposed by the user... this can be done similarly in properties file.
For instance, in XML
<main>
<sub1>
<sub11/>
<sub12/>
</sub1>
</sub2>
</main>

Can be written as
main.sub1.sub11=
main.sub1.sub12=
main.sub2 =

My point is that XML structure/heirarchy can be imposed on properties file.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5

We used to see a lot of properties files like that in JRun servlet configuration before the servlet API added web.xml
they were a real pain to track, write and edit.
By going to XML you can use the XSLT, Xquery, Xpath, namespaces, entities, DTDs and Schema.
Nothing similar exists for properties.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML vs Properties file