Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2005

Tip: Looking for answers? Try searching our database.

Append xml record

Thread view: 
terry - 06 Aug 2004 16:58 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.