NewParser Property

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - DOM Reference

NewParser Property

Specifies whether to enable (true) or disable (false) the use of the new parser, which was introduced in MSXML 4.0, to load a DOM document. Setting the NewParser property to false causes subsequent DOM documents to be loaded using the old parser. Setting this property to true causes DOM documents to be loaded using the new parser.

[JScript]

JScript Syntax

domObj.setProperty(strProp, vBool);
vBool = domObj.getProperty(strProp);
[Visual Basic]

Visual Basic Syntax

domObj.setProperty(strProp, vBool)
vBool = domObj.getProperty(strProp)
[C/C++]

C/C++ Syntax

HRESULT setProperty(BSTR strProp, VARIANT vBool);
HRESULT getProperty(BSTR strProp, VARIANT* vBool);

Value

strProp
A BSTR string whose value is "NewParser".
vBool
A VARIANT_BOOL value of true or false. The default value is false.

Remarks

The new parser is faster and more reliable than the old one, but it lacks support for asynchronous loading or DTD validation. The new parser will ignore the async property and throw an exception when validation against a DTD is requested. Therefore, the default value of this property is false.

For example, the following Visual Basic code fragment will fail because validation against a DTD is attempted while using the new parser. The dom object will not be loaded.

Set dom = CreateObject("MSXML2.DOMDocument.5.0")
dom.setProperty "NewParser", true
dom.ValidateOnParse = true
dom.loadXML "<?xml version='1.0' ?><!DOCTYPE root [<!ELEMENT root (#PCDATA)>]><root a='bc'>abc</root>"

However, the above code snippet will work if the ValidateOnParse property is turned off:

dom.ValidateOnParse = false

The following JScript code fragment also works:

dom.setProperty("NewParser", true);
dom.async = true;
dom.load("mytest.xml");

The second line above, however, will be ignored.

Applies To

Component: MSXML 4.0 and later

Interface: IXMLDOMDocument2

Method: setProperty | getProperty