Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

Re: [jdom-interest] append to xml

Thomas Scheffler

2007-05-03

Replies:

> I am trying to appent to existing xml, but something doesn't work
> what am i missing??
> My code
>
> doc = new SAXBuilder()build("file.xml");
>
> Element e = new Element("person");
> e.setAttribute("name", "Joe");
>
> doc.getRootElement().addContent(e);
>
> I get no errors but my xml file is not changed

You just read the xml file and the change you made is transient. To make it
persistent you have to use XMLOutputer and write it back to the file.

Thomas
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.