Solved

Parsing XML response with ASP

Posted on 2004-09-04
11
1,380 Views
Last Modified: 2008-02-01
I am developing a website where I need to parse an XML response form a remote database. I can parse an XML file that is local to my computer but have problems grabbing the XML as an HTTP request.
Any help would be greatly appreciated!  
Eleon
0
Comment
Question by:vcgDevelopers
  • 5
  • 3
  • 3
11 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11980742
Any luck with this:

Function GetHTML(strURL)
      Dim objXMLHTTP, strReturn
      Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
      objXMLHTTP.Open "GET", strURL, False
      objXMLHTTP.Send
      strReturn = objXMLHTTP.responseText
      Set objXMLHTTP = Nothing
      GetHTML = strReturn
End Function

FtB
0
 

Author Comment

by:vcgDevelopers
ID: 11981140
I tried using the function and hard coding the url but can not open the XML response. Is there a chance the MSXML library is not visible?
Eleon
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11981371
I am not sure. If you would like to try this with my site to see, use http://www.FaifieldConsulting.com a shot.

FtB

0
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.

 

Author Comment

by:vcgDevelopers
ID: 11981519
Thanks for you help.  I've been a C programmer and was thrown into the HTML/XML/ASP deep end since no one else in my company wanted to do the job...  Well, I was able to grab the XML response, it turned out to be a password error. The result comes back as a string and is difficult to parse since blanks occur not only between tag values.  Is there a way to get the tag names with the text?
Eleon
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11981536
I thought that did return tag names. Hang on a few minutes...

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11981575
I guess that this just renders the page...

<%
Response.Expires = 0
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"

Function GetHTML(strURL)
     Dim objXMLHTTP, strReturn
     Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
     objXMLHTTP.Open "GET", strURL, False
     objXMLHTTP.Send
     strReturn = objXMLHTTP.responseText
     Set objXMLHTTP = Nothing
     GetHTML = strReturn
End Function

 response.write(GetHtml("http://www.FairfieldConsulting.com/datacontent.xml"))

 %>
0
 

Author Comment

by:vcgDevelopers
ID: 11981606
What is the best way to grab the return, xsl stylesheets?  I may have to run out and buy another book..
Eleon
0
 
LVL 4

Expert Comment

by:divt
ID: 11982075
vcg, you may want to try this for grabing return from a url, if you have trouble with MSXML

<%

Dim URL

URL = "http://google.com"
HtmlDump = HttpRequest(URL)

if IsNull(HtmlDump) then
    response.write "problem with URL - " & URL
else
    response.write "html dump from URL - " & URL
    response.write "<form><textarea cols='80' rows='20'>"
    response.write HtmlDump
    response.write "</textarea></form>"

end If
response.end

Function HttpRequest(ByVal URL)

    Set WinHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
    WinHttpReq.Open "GET", URL, False
    WinHttpReq.Send
   
    If WinHttpReq.status = 200 Then
            HttpRequest = WinHttpReq.ResponseText
    Else
           HttpRequest = Null
    End If

    Set WinHttpReq = Nothing

End Function
%>

Let me know if this works for you.
0
 
LVL 4

Expert Comment

by:divt
ID: 11982084
0
 
LVL 4

Expert Comment

by:divt
ID: 11982102
After re-reading your question, I guess you have no problem with parsing the XML, please just ignore the previous comment. :-)
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 500 total points
ID: 11982334
>>What is the best way to grab the return, xsl stylesheets?  I may have to run out and buy another book..<<

http://www.w3schools.com

There are three or four quick tutorials that might put you on the correct path.

FtB
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Send to Print Preview database record with one click 3 61
Connection to multiple databases 13 26
Filktering Alphabetically 8 32
Set time on Session (ASP) 14 23
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

821 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