Discussion:
Deleting a text node
(too old to reply)
frameexpert
2006-09-17 12:56:16 UTC
Permalink
I want to delete the text from an element. I am simply setting the
element's text property to a null string.

oElement.text = "";

This works, but is there an MSXML function that does the same thing?
Thanks.

Rick Quatro
Martin Honnen
2006-09-17 14:48:29 UTC
Permalink
Post by frameexpert
I want to delete the text from an element. I am simply setting the
element's text property to a null string.
oElement.text = "";
This works, but is there an MSXML function that does the same thing?
Using the text property of MSXML is fine I think. Why do you need a
function?

You could do e.g.
while (oElement.hasChildNodes()) {
oElement.removeChild(oElement.lastChild);
}
if you wanted to use a general approach using only stuff that the W3C
DOM specifies. The text property is an MSXML extension.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Continue reading on narkive:
Loading...