Solved

objXMLDOM.Load From URL?

Posted on 2002-03-29
4
302 Views
Last Modified: 2008-03-06
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("Microsoft.XMLDOM")
 
  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
0
Comment
Question by:daveamour
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:ASPGuru
Comment Utility
lookup XMLHTTP in you documentation

ASPGuru
0
 
LVL 19

Author Comment

by:daveamour
Comment Utility
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.XMLHTTP")
  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
 
  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("Microsoft.XMLDOM")
 
  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
0
 
LVL 11

Accepted Solution

by:
ASPGuru earned 25 total points
Comment Utility
yes you can do without saving...
instead of this:
xmlGet = objXML.responseText
you can do this:
Set xmlDoc = objXML.responseXML

xmlDoc is a Microsoft.XMLDOM object...

another suggestion:

the Microsoft.XMLDOM and Microsoft.XMLHTTP objects are actually old versions of the xml objects.

newer versions of the objects are downloadable from microsoft and comes with every IE...

the new names are:
Msxml2.DOMDocument
and
Msxml2.XMLHTTP
0
 
LVL 19

Author Comment

by:daveamour
Comment Utility
Thanks dude!

Dave
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now