data Property (IXMLDOMCharacterData)
Stores the node data depending on the node type.
[Script]
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.4.0");
var comment;
var root;
xmlDoc.async = false;
xmlDoc.loadXML("<root><!-- Hello --></root>");
root = xmlDoc.documentElement;
for (var i=0; i<root.childNodes.length; i++) {
if (root.childNodes.item(i).nodeType == 8) {
comment = root.childNodes.item(i);
alert(comment.data);
}
}
[Visual Basic]
Visual Basic Syntax
strValue = oXMLDOMCharacterData.data
objXMLDOMCharacterData.data = strValue
Example
The following Microsoft® Visual Basic® example walks the document tree and checks for comment node types. If one is found, it displays its contents with the data property.
Dim xmlDoc As New DOMDocument40
Dim comment As IXMLDOMComment
Dim root As IXMLDOMElement
xmlDoc.async = False
xmlDoc.loadXML ("<root><!-- Hello --></root>")
Set root = xmlDoc.documentElement
For i = 0 To (root.childNodes.length - 1)
If root.childNodes.Item(i).nodeType = NODE_COMMENT Then
Set comment = root.childNodes.Item(i)
MsgBox comment.Data
End If
Next
[C/C++]
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_data only)
- The value returned if there is no character data node.
- E_INVALIDARG (for get_data only)
- The value returned if data is Null.
- E_FAIL (for put_data only)
- 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. |
To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button
in the upper-left corner of the page.
See Also
IXMLDOMNode | nodeType Property | nodeValue Property
Applies to: IXMLDOMCDATASection | IXMLDOMCharacterData | IXMLDOMComment | IXMLDOMText