Solved

Parsing XML response with ASP

Posted on 2004-09-04
11
1,390 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
[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
  • 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
Independent Software Vendors: 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!

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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
How to alternate between 2 messages until page closes in Classic ASP 8 46
Html Table looping 4 43
Reg Exp to extract Url from string asp 12 61
SQL to JSON 14 65
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 informatio…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…

752 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