Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help in replacing a node value

 
Preetish Panda
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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.

 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
I resolved it using jdom and inbuilt SAXBuilder class .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic