Here is what I am trying to do.
- Read entire XML file (I do not care the name of element or attribute,etc..).
- Save the read XML file into memory.
- Update some values of read xml file.
- Write back to a XML file.
I am trying to use XMLStreamReader to read a XML file, however all the examples I see so far, it looks like i have to provide element name. But, I do not care about element names, just want to read entier XML file into memory. And, I am not sure how datatype I should be storing as I am reading. I am thinking to store them into Document datatype.
Any suggestions on how to read entire XML file and store read contents in memeory?
Thanks.
The easiest way to do this would be with JAXB. You can use
xjcto generate Java classes from your XML schema. Then use JAXB to unmarhsal (load) your data, manipulate the Java object just as you normally would any other object (using getters/setters), and marshal (save) it back to an XML file.You could also use DOM directly, but manipulating the DOM is a lot more tedious than working with POJOs that directly mirror your XML structure.