daveamour
asked on
objXMLDOM.Load From URL?
I have the following ASP code which works great. What I want to do though is load the xml from a url over http. I know I can use a dll to grab the url stream then save this to a localdisk file and do it that way. Can you bypass teh save to disk bit though and load xml directly into the parser?
Thanks
Dave
Dim objXMLParser
Dim rootNode
Set objXMLDOM = Server.CreateObject("Micro soft.XMLDO M")
objXMLDOM.async = False
objXMLDOM.Load (Server.MapPath("/Xml Stuff/Friends.xml"))
Set rootNode = objXMLDOM.documentElement
If rootNode.hasChildNodes() Then
For Each friend in rootNode.childNodes
For Each item in friend.childNodes
Response.Write item.nodeName & ": " & item.Text & "<br/>"
Next
Response.Write "<hr/>"
Next
End If
Thanks
Dave
Dim objXMLParser
Dim rootNode
Set objXMLDOM = Server.CreateObject("Micro
objXMLDOM.async = False
objXMLDOM.Load (Server.MapPath("/Xml Stuff/Friends.xml"))
Set rootNode = objXMLDOM.documentElement
If rootNode.hasChildNodes() Then
For Each friend in rootNode.childNodes
For Each item in friend.childNodes
Response.Write item.nodeName & ": " & item.Text & "<br/>"
Next
Response.Write "<hr/>"
Next
End If
ASKER
Thanks due. Me is a bit thick though and needs things pointing out. I managed to get something working with XMLHTTP but I had top save it to disk.
This is what I have below, can I do this without saving to disk though?
Dim objXML
Dim objFSO
Dim objFile
Set objXML = CreateObject("Microsoft.XM LHTTP")
Set objFSO = Server.CreateObject("Scrip ting.FileS ystemObjec t")
strURL = "http://localhost/xml%20stuff/Friends.xml"
objXML.Open "GET", strURL, False
objXML.Send
xmlGet = objXML.responseText
Set objFile = objFSO.OpenTextFile (Server.MapPath("/xml stuff/downloads/") & "\" & "friends.xml", 2, True)
objFile.Write xmlGet
Set objFile = Nothing
Set objFSO = Nothing
Dim objXMLParser
Dim rootNode
Set objXMLDOM = Server.CreateObject("Micro soft.XMLDO M")
objXMLDOM.async = False
objXMLDOM.Load (Server.MapPath("/Xml Stuff/Friends.xml"))
Set rootNode = objXMLDOM.documentElement
If rootNode.hasChildNodes() Then
For Each friend in rootNode.childNodes
For Each item in friend.childNodes
Response.Write item.nodeName & ": " & item.Text & "<br/>"
Next
Response.Write "<hr/>"
Next
End If
Thanks
Dave
This is what I have below, can I do this without saving to disk though?
Dim objXML
Dim objFSO
Dim objFile
Set objXML = CreateObject("Microsoft.XM
Set objFSO = Server.CreateObject("Scrip
strURL = "http://localhost/xml%20stuff/Friends.xml"
objXML.Open "GET", strURL, False
objXML.Send
xmlGet = objXML.responseText
Set objFile = objFSO.OpenTextFile (Server.MapPath("/xml stuff/downloads/") & "\" & "friends.xml", 2, True)
objFile.Write xmlGet
Set objFile = Nothing
Set objFSO = Nothing
Dim objXMLParser
Dim rootNode
Set objXMLDOM = Server.CreateObject("Micro
objXMLDOM.async = False
objXMLDOM.Load (Server.MapPath("/Xml Stuff/Friends.xml"))
Set rootNode = objXMLDOM.documentElement
If rootNode.hasChildNodes() Then
For Each friend in rootNode.childNodes
For Each item in friend.childNodes
Response.Write item.nodeName & ": " & item.Text & "<br/>"
Next
Response.Write "<hr/>"
Next
End If
Thanks
Dave
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks dude!
Dave
Dave
ASPGuru