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

setProperty Method

This method is used to set second-level properties on the DOM object.

[Script]

Script Syntax

objXMLDOMDocument2.setProperty(name, value);

Parameters

name
The name of the property to be set. For a list of properties that can be set using this method, see second-level properties .
value
The value of the specified property. For a list of property values that can be set using this method, see second-level properties .

Example

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0");
var selection;
xmlDoc.loadXML("<Customer><Name>Microsoft</Name></Customer>");
xmlDoc.setProperty("SelectionLanguage", "XPath");
selection = xmlDoc.selectNodes("Customer/Name");
alert(selection.expr + " -- " + selection.item(0).xml);

The preceding message box displays "Customer/Name -- <Name>Microsoft</Name>".

selection.expr = "/Customer";
alert(selection.expr + " -- " + selection.item(0).xml);

The preceding message box displays "/Customer –-<Customer><Name>Microsoft</Name></Customer>".

[Visual Basic]

Visual Basic Syntax

objXMLDOMDocument2.setProperty(name, value)

Parameters

name
The name of the property to be set. For a list of properties that can be set using this method, see second-level properties .
value
The value of the specified property. For a list of property values that can be set using this method, see second-level properties .

Example

Dim xmldoc As New Msxml2.DOMDocument50
Dim selection As Msxml2.IXMLDOMSelection

xmldoc.loadXML ("<Customer><Name>Microsoft</Name></Customer>")
xmldoc.setProperty "SelectionLanguage", "XPath"
Set selection = xmldoc.selectNodes("Customer/Name")
MsgBox selection.expr + " -- " + selection.Item(0).xml

The preceding message box displays "Customer/Name -- <Name>Microsoft</Name>".

selection.expr = "/Customer"
MsgBox selection.expr + " -- " + selection.Item(0).xml

The preceding message box displays "/Customer –-<Customer><Name>Microsoft</Name></Customer>".

[C/C++]

C/C++ Syntax

HRESULT setProperty (BSTR name, VARIANT value);

Parameters

name [in]
The name of the property to be set. For a list of properties that can be set using this method, see second-level properties .
value [in]
The value of the specified property. For a list of property values that can be set using this method, see second-level properties .

C/C++ Return Values

S_OK
Value returned if successful.
E_FAIL
Value returned if name or value is invalid.

Remarks

Examples of the second-level properties include SelectionLanguage, ValidateOnParse, ServerHTTPRequest.

This method may not be applied to the first-level DOM properties that are exposed directly on a DOM object. Examples of the first-level properties include validateOnParse, async, parseError, etc.

To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

selectSingleNode Method | selectNodes Method | document Function | second-level properties | getProperty Method

Applies to: IXMLDOMDocument2