Export (0) Print
Expand All
XML
Expand Minimize

validate Method

Windows Mobile 6.5
A version of this page is also available for
4/8/2010

Performs run-time validation on the currently loaded document using the currently loaded document type definition (DTD), schema, or schema collection.

objXMLDOMDocument2.validate();

A ParseError object indicating exactly what error occurred, if any.

HRESULT validate(
  IXMLDOMParseError** errorObj
);

errorObj

[retval, out] IErrorInfo containing a formatted error message indicating exactly what went wrong and one of the following HRESULTs (also returned in the ErrorInfo.Number property).

Return value Hexadecimal value Description

E_PENDING

0x8000000A

Document readyState Property (DOMDocument) is not 4, indicating the document is not completely loaded.

S_OK

0

The document is valid according to DTD or schemas.

S_FALSE

1

The document is invalid according to DTD or schemas. For error information, see the returned IXMLDOMParseError object.

The following possible validation errors returned with S_FALSE are listed, together with the errorCode value.

Message ID Error Code (Hex Value) Message

XML_E_NODTD

0xC00CE224

Validate failed because a DTD or schema was not specified in the document.

XML_E_NOTWF

0xC00CE223

Validate failed because the document does not contain exactly one root node.

XML_ENTITY_UNDEFINED

0xC00CE002

Reference to undefined entity '%1'.

XML_INFINITE_ENTITY_LOOP

0xC00CE003

Entity '%1' contains an infinite entity reference loop.

XML_NDATA_INVALID_PE

0xC00CE004

Cannot use the NDATA keyword in a parameter entity declaration.

XML_REQUIRED_NDATA

0xC00CE005

Cannot use a general parsed entity '%1' as the value for attribute '%2'.

XML_NDATA_INVALID_REF

0xC00CE006

Cannot use unparsed entity '%1' in an entity reference.

XML_EXTENT_IN_ATTR

0xC00CE007

Cannot reference an external general parsed entity '%1' in an attribute value.

XML_ELEMENT_UNDECLARED

0xC00CE00D

The element '%1' is used but not declared in the DTD or schema.

XML_ELEMENT_ID_NOT_FOUND

0xC00CE00E

The attribute '%1' references the ID '%2', which is not defined in the document.

XML_EMPTY_NOT_ALLOWED

0xC00CE011

Element cannot be empty according to the DTD or schema.

XML_ELEMENT_NOT_COMPLETE

0xC00CE012

Element content is incomplete according to the DTD or schema.

XML_ROOT_NAME_MISMATCH

0xC00CE013

The name of the top-most element must match the name of the DOCTYPE declaration.

XML_INVALID_CONTENT

0xC00CE014

Element content is invalid according to the DTD or schema.

XML_ATTRIBUTE_NOT_DEFINED

0xC00CE015

The attribute '%1' on this element is not defined in the DTD or schema.

XML_ATTRIBUTE_FIXED

0xC00CE016

Attribute '%1' has a value that does not match the fixed value defined in the DTD or schema.

XML_ATTRIBUTE_VALUE

0xC00CE017

Attribute '%1' has an invalid value according to the DTD or schema.

XML_ILLEGAL_TEXT

0xC00CE018

Text is not allowed in this element according to DTD or schema.

XML_MULTI_FIXED_VALUES

0xC00CE019

An attribute declaration cannot contain multiple fixed values: '%1'.

XML_ELEMENT_UNDEFINED

0xC00CE01C

Reference to undeclared element: '%1'.

XML_XMLNS_FIXED

0xC00CE01E

Attribute '%1' must be a #FIXED attribute.

XML_REQUIRED_ATTRIBUTE_MISSING

0xC00CE020

Required attribute '%1' is missing.

XML_DTD_EXPECTING

0xC00CE026

Expecting: %1.

XML_E_NODTD

0xC00CE224

Validate failed because a DTD or schema was not specified in the document.

Headermsxml2.h, msxml2.idl
Libraryuuid.lib
Windows Embedded CEWindows CE .NET 4.0 and later

This method only validates fully loaded documents (readyState == 4).

The validate method returns IXMLDOMParseError that is independent of the value returned by the parseError property on a document. Only the errorCode and reason properties of the returned value are set.

Unlike load, validate will fail if there is no DTD or schema applied to the document element. Therefore, validate will not be able tell you whether the document is just well-formed.

The validate method does not parse new schemas, but can import a schema from a SchemaCache associated with the document through the schemas property. If there is no schema for a given namespace, the elements in that namespace will not be validated.

This method applies to the following interface:

IXMLDOMDocument2.

Community Additions

ADD
Show:
© 2014 Microsoft