I want to use XML file as database. Where I want to store an ID and its correspondingly a String path. Like:
<item>
<Id>id</Id>
<Path>path</Path>
</item>
or like that. Now in runtime a Name-Value Collection will load this data stored in XML document and check the Id against some data and will be processed accordingly and also update (that is change path of same Id)and delete(removal of an existing item) of items is needed in that XML file. Hope I make you able to understand my idea! I have no code to show as this is in conceptual level. What I need is that how can I achieve this, is there any tutorial I can read or API available which is able to do this? Thank you. I am in JAVA.
On the other hand you are closer to XML if you use XML-Database Systems, which offer XML database APIs. Like Exist or Apache Xindice.
I'll assume this is actually a good idea for your application - that's a whole different discussion.
I would treat this as three separate problems:
Map<String, String>
)Most of your code should probably be unaware that your collection will be stored in XML.
There are various XML APIs available for Java - the built-in ones tend to be quite a pain to use. I don't know what the latest and greatest ones are, but historically JDOM has proved fairly simple.
Note that your choice of in-memory collection will depend on your requirements - is the ordering important, for example?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With