validateNode Method
[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.
JScript Syntax
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);
Parameters
node
An IXMLDOMNode
object representing the node from which the fragment or sub-tree expands.
objErr
A reference to the IXMLDOMParseError
object that indicates exactly what error occurred, if any. Use the properties on this object to examine specific parse error information.
Return Values
S_OK
Validation was successful.
E_FAIL
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.
S_FALSE
Validation errors were encountered. Check the returned objErr
object for detailed parse error information.
Note
This method returns the same HRESULT
value that is returned by the IXMLDOMDocument2::import
method.
Remarks
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.
Example
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.
Applies to
Versioning
Implemented in: MSXML 5.0 for Microsoft Office Applications and later
See Also
IXMLDOMNode
IXMLDOMNodeList
IXMLDOMParseError
IXMLDOMSchemaCollection-XMLSchemaCache