Using Java, could I append new record into a xml file?
The xml file example is in the following:
<?xml version='1.0' encoding='utf-8'?>
<test>
<emp>
<id>1</id>
<name>Terry</name>
<position>Doctor</position>
</emp>
<emp>
<id>2</id>
<name>Kitty</name>
<position>Nurse</position>
</emp>
<emp>
<id>3</id>
<name>Candy</name>
<position>Nurse</position>
</emp>
</test
Sudsy - 06 Aug 2004 17:24 GMT
> Using Java, could I append new record into a xml file?
<snip>
Sure! See the W3C specs for DOM:
<http://www.w3.org/TR/DOM-Level-2-Core/>
It's supported by any number of packages. I use Xerces (Apache) and
Oracle xdk.
Brian Palmer - 06 Aug 2004 21:03 GMT
> Using Java, could I append new record into a xml file?
Depending how you mean append. XML requires everything to be nested
within a root, so you could insert a new <emp> element inside of
<test>, but note that </test> has to be outside of it. So you can't
just append at the end of the file. There are many ways of writing out
a new bit of XML that has all of the elements that were there prior
and also has the new element, though.
I usually use JDOM to work with xml (http://www.jdom.org )
Jemima - 31 Mar 2005 17:05 GMT
hi
i need help in appending elements to existing XML file.
i have a xml file: Person.xml
<?xml version="1.0" encoding="UTF-8"?>
<PersonInfo>
<Person firstname="jemima" lastname="vijayanand"/>
<Age>20</Age>
</PersonInfo>
i want to add/append another <Person ...>/<Person> element and <Age></Age>
element.
I wrote a JSP program using JDOM which creates this XML file(Person.xml).
So i like/want to use JDOM to append element to the XML file.
Can anybody give me a suggestions? Any help is appreciated.
thanks.
jemi