[jdom-interest] (no subject)

Crook, Charles CrookC at tvratings.com
Wed Jun 7 09:52:19 PDT 2000

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

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


   see this code snippet;

org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder();
             Document doc = builder.build(new 
              			Element element=doc.getRootElement();
			Element kid= element.getChild("rating");
			   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:

More information about the jdom-interest mailing list