Append xml record

T

terry

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>
 
B

Brian Palmer

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 )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top