Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to insert Text physically to xml in xml Element

843834Jan 30 2008 — edited Jan 31 2008
hello friends,
I am newb of jDom. i am trying to change xml "Element's"--->"Text". My xml is as follows .....
 
<?xml version ="1.0"> 
<Elements> 
         <code> 
                   <data>EE550</data> 
         </code> 
</Elements> 
I am trying to replace that "<data>" by <data>AA550</data>

my code is as below
 

             SAXBuilder sb = new SAXBuilder(); 
             Document doc = sb.build(new File("src/xml/M90EE.xml")); 
    
             Element element = doc.getRootElement(); 
             List children = element.getChildren(); 
             String key = (element.getChild("text").getChild("mkey").setText("AA550").getTextTrim());   System.out.println("mkey       :"+key); 
 
output: 
mkey   :AA550 
but is it possible to change in the xml file phisically.

thanQ
Ajay
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 28 2008
Added on Jan 30 2008
8 comments
559 views