|
' Loading a document from a url
Set oHttp = CreateObject("Msxml2.serverXMLHTTP")
oHttp.open "GET", "http://www.richmore.com/myFile.xml",False
oHttp.send
set xmlDoc = oHttp.responseXML
' ########################################
' Error checking and loading from a local file
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
' If there is an error creating Msxml2.DOMDocument try without the '2'
' Set xmlDoc = CreateObject("Msxml.DOMDocument")
' If this works download version 3 of the XML DOM: See links below
xmlDoc.async = False
xmlDoc.setProperty "SelectionLanguage","XPath"
if ( xmlDoc.load(Server.MapPath("myFile.xml")) ) then
else
Set xPE = xmlDoc.parseError
With xPE
strErrText = "Your XML Document failed to load " & _
"due the following error." & vbCrLf & _
"Error #: " & .errorCode & ": " & xPE.reason & _
"Line #: " & .Line & vbCrLf & _
"Line Position: " & .linepos & vbCrLf & _
"Position In File: " & .filepos & vbCrLf & _
"Source Text: " & .srcText & vbCrLf & _
"Document URL: " & .url
Response.Write("Error: <PRE>" & strErrText & "</PRE>")
End With
end if
xmlDoc.setProperty "SelectionLanguage","XPath"
set root = xmlDoc.documentElement
if root is nothing then
Response.Write("<BR>Root is nothing")
end if
set node = root.selectSingleNode("")
' Extract Node Values
Response.Write(node.selectSingleNode("Name").Text)
' Extract Attributes
Set idAttr = node.selectSingleNode("Book").Attributes.getNamedItem("ID")
Response.Write(idAttr.value)
' Test if node exists before extracting text
set tmpNode = node.selectSingleNode("Publisher")
if tmpNode is nothing then
publisher = " "
else
publisher = tmpNode.Text
end if
Response.Write(publisher)
Set sections = root.selectNodes("*")
if sections.length = 0 then
Response.Write("No books found")
end if
For Each node In sections
' Extract the name of the node
if node.nodeName = "Book" then
else
endif
Next
<SCRIPT LANGUAGE=JavaScript>
// send XML documento to Web server
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST","./file_recieve.asp",false);
xmlhttp.send(xml_dom);
// show server message in message-area
div_message.innerHTML = xmlhttp.ResponseText;
}
</SCRIP>T
# Server Side
set xml_dom = Server.CreateObject("MSXML2.DOMDocument")
xml_dom.load(request)
|