<entry key="key">value</entry> or
<entry key="key" value="value" />
(im not that bothered about doctypes etc, as long as i can load the data to the hashmap when the program starts and then save the hashmap back to the file once the program has run)
i really dont have any experience with using xml in java, so any help you could give would be much appreciated
A map like:
Here is a sample (I used one from Jakarta and used a map instead of a bean):
You'll need at least:
Originally posted by William Brogden:
In Java 1.5 the java.util.Properties class got a loadFromXML and a storeToXML method. Properties is an extension of Hashtable and implements Map.
Perhaps that will handle your problem without going to another library.
i did try this already but i had a few problems, first properties only stores String, String. my map is String, integer. id rather not have to go through converting the integers to srtings and vice versa
the second problem i had (im guessing) is with the way i implemented the code, my xml always turned out like this
Satou: i had a look at your example too, but in my code i define the hashmap:
i take it this wont make any difference to the example you posted?
first, how do i load the xml file back into a hashmap, and
second, the xml file generated by this example comes out all in one long line rather than being nicely spaced and indented, will this affect the functionality of the program, and is it possible to correct this?
[ June 09, 2006: Message edited by: colin mcculloch ]
As for reading the text back from the file, you could:
And you do the DOM structure parsing.
[ June 09, 2006: Message edited by: Edwin Dalorzo ]