| Author |
Replacing the content of a node with a text string
|
Miguel Capo
Greenhorn
Joined: Oct 08, 2006
Posts: 14
|
|
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
Joined: Mar 22, 2000
Posts: 12271
|
|
In the org.w3c.dom.Node class there is the replaceNode(Node newChild, Node oldChild) method. See the JavaDocs for details. Bill
|
Java Resources at www.wbrogden.com
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
|
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).
|
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
|
 |
 |
|
|
subject: Replacing the content of a node with a text string
|
|
|