Solved

objXMLDOM.Load From URL?

Posted on 2002-03-29
4
366 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:ASPGuru
ID: 6906715
lookup XMLHTTP in you documentation

ASPGuru
0
 
LVL 19

Author Comment

by:daveamour
ID: 6907119
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
ID: 6907254
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
ID: 6907404
Thanks dude!

Dave
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

630 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