Solved

Parsing XML response with ASP

Posted on 2004-09-04
11
1,351 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

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/…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 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