Solved

Parsing XML response with ASP

Posted on 2004-09-04
11
1,362 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
pass url parameter as session 9 48
Group by correlation 4 55
Copy only dates 3 80
I am getting ASP error  xmlParseEntityRef: no name. Anyone can help ? 1 46
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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now