setProperty Method
Sets the SelectionLanguage, ServerHTTPRequest, SelectionNamespaces or NewParser internal properties (flags).
Important For servers running on an intranet, the ServerHTTPRequest property requires you to run a proxycfg.exe utility to configure WinHTTP's proxy settings. They cannot be configured through the Microsoft® Windows® Control Panel. To download the proxy configuration utility, go to the XML Development Center's
WinHTTP Proxy Configuration Utility page. For instructions about running the proxycfg.exe utility, see Using the WinHTTP Proxy Configuration Utility. After you have run the proxycfg.exe tool and updated the registry, the previous registry settings cannot be restored.
[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 Remarks.
- value
- The value of the specified property. For a list of property values that can be set using this method, see Remarks.
Example
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.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 Remarks.
- value
- The value of the specified property. For a list of property values that can be set using this method, see Remarks.
Example
Dim xmldoc As New Msxml2.DOMDocument40
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 Remarks.
- value [in]
- The value of the specified property. For a list of property values that can be set using this method, see Remarks.
C/C++ Return Values
- S_OK
- Value returned if successful.
- E_FAIL
- Value returned if name or value is invalid.
Remarks
The following table shows the properties that you can set using this method. Existing properties from DOMDocument are not accessible through this method. White space is not stripped or normalized in property names or values.
| Name |
Value |
| SelectionLanguage internal property (flag) |
"XPath"
This flag applies to all nodes whose ownerDocument property points to this document object. Therefore, if a given node is moved to a different document, its selectNode behavior may change depending on the SelectionLanguage setting in the new document.
The following Jscript example on the client shows how to set the SelectionLanguage to XPath for the xmldoc object.
var xmldoc = new ActiveXObject("Msxml2.DOMDocument.4.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);
|
| ServerHTTPRequest internal property (flag) |
True/False value indicates if Microsoft Windows HTTP Services (WinHTTP) API will be used during loading of XML DOM objects instead of Microsoft Windows Internet Services (WinInet) API.
If True, the WinHTTP API will be used during loading of XML DOM objects. If False, the WinInet API will be used instead.
This only supports synchronous loading; thus, the async property must be set to False when this property is set to True.
For example:
<%@language=JScript%>
<%
var xmldoc;
xmldoc = Server.CreateObject("Msxml2.DOMDocument.4.0");
xmldoc.async = false;
xmldoc.setProperty("ServerHTTPRequest", true);
xmldoc.load(http://myserver.com);
%>
|
| SelectionNamespaces internal property (flag) |
A space delimited set of Namespace names.
For example:
xmldoc.setProperty("SelectionNamespaces",
"xmlns:example1='http://myserver.com'
xmlns:example2='http://yourserver.com'");
With the SelectionNamespaces internal property (flag), the selectSingleNode method and selectNodes method can now use qualified names.
|
| NewParser internal property (flag) |
True/False value indicating whether MSXML uses the old or new internal parser when loading DOMDocument objects.
This property is transitional for the period while MSXML provides a choice of two internal parsers. The new parser is faster and more reliable, but it does not yet support asynchronous mode or DTD validation.
If the newParser property is set to False, which is the current default setting, subsequent DOMDocument objects are loaded using the old parser.
If this property is set to True, subsequent DOMDocument objects are loaded using the new parser.
For example, the following code makes a DOMDocument object use the new parser when loading.
xmldoc.setProperty("NewParser", True );
Note Once the new parser has been updated to provide for asynchronous mode and DTD validation, this property will always be set to True.
|
To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button
in the upper-left corner of the page.
See Also
selectSingleNode Method | selectNodes Method
Applies to: IXMLDOMDocument2