Validates a specified DOM fragment. A DOM fragment is a sub-tree spanning from a given node.
var objErr = objXMLDOMDocument3.validateNode(node);
Visual Basic Syntax
Set objErr = objXMLDOMDocument3.validateNode(node);
C/C++ Syntax Using Smart Pointers
IXMLDOMParseErrorPtr objErr = objXMLDOMDocument3->validateNode(node);
HRESULT IXMLDOMDocument3::validateNode( ...[in] IXMLDOMNode* node, ...[out, retval] IXMLDOMParseError** objErr);
IXMLDOMNodeobject representing the node from which the fragment or sub-tree expands.
- A reference to the
IXMLDOMParseErrorobject that indicates exactly what error occurred, if any. Use the properties on this object to examine specific parse error information.
- Validation was successful.
- The node failed to validate for one of the following reasons:
- The DOM document was not completely loaded
- The DOM node does not belong to this DOM document instance
- The DOM node type was not element or attribute.
- Validation errors were encountered. Check the returned
objErrobject for detailed parse error information.
Note This method returns the same
HRESULTvalue that is returned by the
In the syntax for Visual Basic and JScript above, an
objXMLDOMDocument3 object is a
DOMDocument instance that implements the
validateNode will not cause a new schema to load. Furthermore,
validateNode assumes that the rest of the document is valid. Without this assumption it would not be possible to validate ID/IDREFs at all with the
validateNode method is applicable only to element or attribute nodes located within the same DOM document. Any attempt to call it on other types of nodes or nodes in other DOM documents results in an error.
The validateNode example shows how to validate a DOM fragment at run time. The example uses two resource files, validateNode.xml and validateNode.xsd. The first is an XML data file, and the second is the XML Schema for the XML data. The first
<book> element in validateNode.xml is valid against validateNode.xsd; the second
<book> element is not.
We've provided source files for the sample in three languages: JScript, Visual Basic, and C++. The output is the same in each language.
- Resource Files (validateNode.xml and validateNode.xsd)
- JScript Code (validateNode.js)
- Visual Basic Code (validateNode.frm)
- C/C++ Code (validateNode.cpp)
- Output for validateNode Example
MSXML 5.0 and later
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.