nodeValue Property


Contains the text associated with the node.

objValue = oXMLDOMNode.nodeValue;  
objXMLDOMNode.nodeValue = objValue;  


The following script example creates an IXMLDOMNode object and tests if it is a comment node. If it is, it displays its value.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var currNode;
xmlDoc.async = false;
xmlDoc.loadXML("<root><!-- Hello --></root>");
if (xmlDoc.parseError.errorCode != 0) {
   var myErr = xmlDoc.parseError;
   WScript.Echo("You have error " + myErr.reason);
} else {
   currNode = xmlDoc.documentElement.childNodes.item(0);
   if (currNode.nodeTypeString == "comment") {

objValue = oXMLDOMNode.nodeValue  
objXMLDOMNode.nodeValue = objValue  

HRESULT get_nodeValue(  
    VARIANT *value);  
HRESULT put_nodeValue(  
    VARIANT value);  


value[out, retval][in]
Node value; depends on the nodeType property.

C/C++ Return Values

Value returned if successful.

S_FALSE (for get_nodeValueonly)
Value when returning Null.

E_INVALIDARG (for get_nodeValueonly)
Value returned if the value parameter is Null.

E_FAIL (for get_nodeValueonly)
Value returned if an error occurs.

Variant. The property is read/write.

This value depends on the value of the nodeType property.

NODE_ATTRIBUTEContains a string representing the value of the attribute. For attributes with subnodes, this is the concatenated text of all subnodes with entities expanded. Setting this value deletes all children of the node and replaces them with a single text node containing the value written.
NODE_CDATA_SECTIONContains a string representing the text stored in the CDATA section.
NODE_COMMENTContains the content of the comment, exclusive of the comment's start and end sequence.






Contains Null. Note that attempting to set the value of nodes of these types generates an error.
NODE_PROCESSING_INSTRUCTIONContains the content of the processing instruction, excluding the target. (The target appears in the nodeName property.)
NODE_TEXTContains a string representing the text stored in the text node.

Implemented in:

MSXML 3.0, MSXML 6.0

IXMLDOMAttribute | IXMLDOMCDATASection | IXMLDOMCharacterData | IXMLDOMComment | IXMLDOMDocument-DOMDocument | IXMLDOMDocumentFragment | IXMLDOMDocumentType | IXMLDOMElement | IXMLDOMEntity | IXMLDOMEntityReference | IXMLDOMNode | IXMLDOMNotation | IXMLDOMProcessingInstruction | IXMLDOMText

nodeName Property1
nodeType Property1