Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Replacing the content of a node with a text string

 
Miguel Capo
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I need to replace a couple of nodes that contain childnodes etc with just a text node. Does anybody know a quick way of doing this?

Is the best way to create a node with the same name etc but just with the text node that I want to insert and the use the replaceChild method of the Node interface? or is there a simpler way?

Thanks
[ November 03, 2006: Message edited by: Miguel Capo ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13062
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the org.w3c.dom.Node class there is the
replaceNode(Node newChild, Node oldChild)
method. See the JavaDocs for details.
Bill
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm in the habit of checking out the Java Developer's Almanac when I need to do something new with the DOM API. You might want to check it out, too (or bookmark it for later).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic