Platform SDK: Exchange 2000 Server |
[This is preliminary documentation and subject to change.]
This example performs a SELECT * search on a folder. Instead of creating an XML string variable for the varHeader parameter to the XMLHTTP object’s Send method, a well-formed XML DOM object is passed.
To accomplish sending an XML DOM object, nodes are appended as necessary. The first node contains a directive in a processing node to set the xml version to 1.0.
Additional nodes are created so that the XML request structure is as follows:
<?xml version="1.0"?> <D:searchrequest xmlns:D = "DAV:" > <D:sql> SELECT * FROM scope('shallow traversal of "http://myServer1/docs/data/"') where "DAV:ishidden" = false AND "DAV:isfolder" = false </D:sql> </D:searchrequest>
This example does not use XSL to render the XLM DOM object returned by the XMLHTTP RequestXML property. Instead, it iterates through an XMLNodeList collection, listing the NodeName and Text property values for the node. Because the XML DOM object obtained from the ResponseXML property contains namespace prefixes, the NamespaceURI property is included in the list as a clarification.
<HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> <TITLE>Simple SEARCH</TITLE> </HEAD> <BODY LANGUAGE="VBScript" onLoad="doXML"> <SCRIPT FOR=WINDOW LANGUAGE=VBSCRIPT> <!-- Sub doXML set doc = createobject("microsoft.xmldom") set docback = createobject("microsoft.xmldom") dim strURL strURL = "http://myServer1/public/docs/" set pi = doc.createProcessingInstruction("xml","version=""1.0""") doc.appendChild pi set node = doc.createNode(1,"searchrequest","DAV:") set doc.documentElement = node set node2 = doc.createNode(1,"sql","DAV:") node.appendChild node2 set query = doc.createTextNode("select * from scope('shallow traversal of """ & strURL & """') where ""DAV:ishidden"" = false AND ""DAV:isfolder"" = false") node2.appendChild query set req = createobject("microsoft.xmlhttp") req.open "SEARCH", strURL, false, "MyServer1\Administrator", "" req.setrequestheader "Translate", "f" req.setrequestheader "Content-Type", "text/xml" req.setrequestheader "Depth", "0" req.send doc set docback = req.responseXML Dim objNodeList Set objNodeList = docback.getElementsByTagName("*") MsgBox Err.Number For i = 0 TO (objNodeList.length -1) Set objNode = objNodeList.nextNode Document.Write("<b>" & objNode.NamespaceURI & " " & objNode.NodeName & "</b> - ") Document.Write(objNode.Text & "<hr>") Next End Sub //--> </SCRIPT> <P> </P> </BODY> </HTML>