[jdom-interest] (no subject)

nagarajan madhavan nagaragan at hotmail.com
Wed Jun 7 10:06:58 PDT 2000


Thanks for ur reply; Will u plz give me a code outline, how to make the 
changes in the original document ?

thanks




>If your doc is parsed in memory, you're only changing the "in-memory"
>version of the file2.xml; not actually writing it back to disk...
>So your output of 0 on the screen, but 400 still in the disk file would be
>expected.
>
>
>-----Original Message-----
>From: nagarajan madhavan [mailto:nagaragan at hotmail.com]
>Sent: Wednesday, June 07, 2000 12:41 PM
>To: jdom-interest at jdom.org
>Subject: [jdom-interest] (no subject)
>
>
>Hello,
>
>    see this code snippet;
>
>
>org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder();
>              Document doc = builder.build(new
>File("E:\\java_classes\\file2.xml"));
>               			Element element=doc.getRootElement();
>			Element kid= element.getChild("rating");
>			kid.setContent("0");
>			   String x  =kid.getContent();
>		System.out.println("value of x-- rating is" +x+"\n\n");
>
>
>"file2"  is an existing xml file;
>
>it has an attribute, by name "rating"  ( <rating>400</rating> ).
>
>In this code we are trying to set that to Zero ( i don't know if it will be
>considered as a  string or is there a way of maintaining the actual data
>type, if any ; because actually "rating" keeps integer values).
>
>
>When we use,
>
>    XMLOutputter fmt = new XMLOutputter();
>       fmt.output(doc, System.out);
>
>
>The output on the console gives the value of "rating" as 0.
>
>But when u open the actual file , "file2.xml", the value of rating is not
>changed; the old 400 only;
>
>The question is how to modify the value of a particular attribute( element)
>in an already existing  XML files ?
>
>Thanks in advance
>
>________________________________________________________________________
>Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
>
>_______________________________________________
>To control your jdom-interest membership:
>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
>t.com
>_______________________________________________
>To control your jdom-interest membership:
>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com




More information about the jdom-interest mailing list