[This sample code uses features that were first implemented in MSXML 5.0 for Microsoft Office Applications.]
Validates a specified DOM fragment. A DOM fragment is a sub-tree spanning from a given node.
IXMLDOMParseErrorPtr objErr = objXMLDOMDocument3->validateNode(node); HRESULT IXMLDOMDocument3::validateNode( ...[in] IXMLDOMNode* node, ...[out, retval] IXMLDOMParseError** objErr);
This method returns the same HRESULT value that is returned by the IXMLDOMDocument2::import method.
In the syntax for Visual Basic and JScript above, an objXMLDOMDocument3 object is a DOMDocument instance that implements the IXMLDOMDocument3 interface.
Unlike IXMLDOMDocument2::validate, 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.
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.