Compartilhar via


data Property (IXMLDOMCharacterData)

 

Stores the node data depending on the node type.

Script Syntax

strValue = oXMLDOMCharacterData.data;  
objXMLDOMCharacterData.data = strValue;  

Example

The following script example walks the document tree and checks for comment node types. If one is found, it displays its contents with the data property.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");  
var comment;  
var root;  
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 {  
   root = xmlDoc.documentElement;  
   for (var i=0; i<root.childNodes.length; i++) {  
      if (root.childNodes.item(i).nodeType == 8) {  
         comment = root.childNodes.item(i);  
         WScript.Echo(comment.data);  
      }  
   }  
}  

Visual Basic Syntax

strValue = oXMLDOMCharacterData.data  
objXMLDOMCharacterData.data = strValue  

C/C++ Syntax

HRESULT get_data(  
    BSTR *strData);  
HRESULT put_data(  
    BSTR strData);  

Parameters

strData[out, retval][in]
The same value as the nodeValue for this node.

C/C++ Return Values

S_OK
The value returned if successful.

S_FALSE (for get_dataonly)
The value returned if there is no character data node.

E_INVALIDARG (for get_dataonly)
The value returned if the data parameter is Null.

E_FAIL (for put_dataonly)
The value returned if an error occurs.

Remarks

String. The property is read/write. It contains the same value as the nodeValue for this node. The meaning of the value depends on the nodeType property of the IXMLDOMNode, as follows.

NODE_CDATA_SECTION A string representing the text stored in the CDATA section.
NODE_COMMENT The content of the comment, exclusive of the comment start and end sequence.
NODE_TEXT A string representing the text stored in the text node.

Versioning

Implemented in:

MSXML 3.0, MSXML 6.0

Applies to

IXMLDOMCDATASection | IXMLDOMCharacterData | IXMLDOMComment | IXMLDOMText

See Also

IXMLDOMNode
nodeType Property1
nodeValue Property