I have an xml file having data, and want to add more to that file when a button is pressed in swing frame-
the xml file is like this -
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
// want to insert data here
how can i do this because every time the button is clicked, i want to store the data from the textfields of the window to an xml file , but i also want the previous data and the current one too.
I want to write the new data in between the <FDdetails> tag each time i click the button.
Can someone please help me with this? Completely exhausted searching on net for tutorials but no success.
the DOM parser is suitable one for this.
first of of parse the XML file.
we have a method in DOM API, which it adds exactly before the paticular tag.
Joined: Mar 22, 2005
<nitpicking>I feel compelled to point out that a parser can't alter anything - parsing XML means the act of reading it. DOM does more than just parse XML, though - it has methods to alter the resulting DOM tree. (And, if one wanted to be even more exacting, DOM doesn't actually do parsing at all- it relies on an underlying SAX parser to do that.)</nitpicking>
Joined: Apr 01, 2009
Thanks everyone, i will now concentrate on using the DOM parser and try to do my program. Thank you all once again for your help.
<extended-nitpicking>Actually, the Simple API for XML (SAX) also does not do any "parsing." It is an API that receives callbacks from an actual parser, e.g. Apache Xerces. Both DOM and SAX are programming API, they are not parsers.</extended-nitpicking>