• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need help in replacing a node value

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to parse XML file in order to update a node value

<abc>
<def>/home/setup</def>
<fgh>encrypted</fgh>
<hij>configuser</hij>
</abc>

I need to update node value of <fgh>

Here is my code .. I'm able to read node value .. but can't update it.Because, for some reason setNodevalue is not working.
Any help is highly appreciated.

 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have committed the common beginner error of assuming that an Element's value is the text in it's only child node. It isn't. Read the API documentation for Node to find out what an Element's value actually is.

And then consider that an Element can have more than one child (as does the <abc> element in your example). If you want to change any of its child nodes (and you do want that) then you will either have to change them, if possible, or create new ones to replace the existing ones.
 
Preetish Panda
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I resolved it using jdom and inbuilt SAXBuilder class .
 
reply
    Bookmark Topic Watch Topic
  • New Topic