Solved

objXMLDOM.Load From URL?

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

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. 
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

809 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