Solved

objXMLDOM.Load From URL?

Posted on 2002-03-29
4
359 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XSLT Help 12 36
any soltion create a connection to import XML file from website 4 62
configure dependency in POM for new database 3 52
ebay devID, appID, certID, userToken 2 113
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…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 

732 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