Stores the node data depending on the node type.
strValue = oXMLDOMCharacterData.data; objXMLDOMCharacterData.data = strValue;
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.5.0");
var comment;
var root;
xmlDoc.async = false;
xmlDoc.loadXML("<root><!-- Hello --></root>");
if (xmlDoc.parseError.errorCode <> 0) {
var myErr = xmlDoc.parseError;
alert("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);
alert(comment.data);
}
}
}
strValue = oXMLDOMCharacterData.data objXMLDOMCharacterData.data = strValue
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 DOMDocument50
Dim comment As IXMLDOMComment
Dim root As IXMLDOMElement
xmlDoc.async = False
xmlDoc.loadXML ("<root><!-- Hello --></root>")
If (xmlDoc.parseError.errorCode <> 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
MsgBox("You have error " & myErr.reason)
Else
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
End If
HRESULT get_data(
BSTR *strData);
HRESULT put_data(
BSTR strData);
nodeValue for this node.get_data only)get_data only)data parameter is Null.put_data only)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.
IXMLDOMNode | nodeType Property | nodeValue Property
Applies to: IXMLDOMCDATASection | IXMLDOMCharacterData | IXMLDOMComment | IXMLDOMText