Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: Parseing XML in ASP Page [Thread Next] Re: Parseing XML in ASP PageTo: NULL Date: 11/2/2005 6:31:00 PM
Earl F. Kimble Jr. wrote:
> Actually the response does not contain a Content-Type of text/xml or
> application/xml.
>
> So I guess there's nothing I can do.
What Content-Type does the response have then? It is anything supposed
to be XML so that it makes sense to parse it with an XML parser?
You can still try to parse something served via HTTP as XML, one way is
not to use XMLHTTP but instead use a DOMDocument and its load method,
that way however you can only do HTTP GET requests.
Another way is to parse the responseStream that XMLHTTP builds yourself
then with a DOMDocument e.g.
Dim HttpRequest, ResponseXML, WellFormed
WellFormed = False
Set HttpRequest = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
HttpRequest.open "GET", _
"http://example.com/whatever", _
False
HttpRequest.send
If HttpRequest.status = 200 Then
If Not HttpRequest.responseXML Is Nothing And _
Not HttpRequest.responseXML.documentElement Is Nothing And _
HttpRequest.responseXML.parseError.errorCode <> 0 Then
Set ResponseXML = HttpRequest.responseXML
WellFormed = True
Else
Set ResponseXML = Server.CreateObject("Msxml2.DOMDocument.3.0")
ResponseXML.async = False
WellFormed = ResponseXML.load(HttpRequest.responseStream)
End If
If WellFormed Then
Response.Write "<p>Got XML document with " & _
ResponseXML.getElementsByTagName("*").length & _
" elements</p>" & VbCrLf
Else
Response.Write "<p>Parsing failed: " & _
ResponseXML.parseError.reason & _
"</p>" & VbCrLf
End If
Else
Response.Write "<p>HTTP status: " & _
HttpRequest.status & " " & _
HttpRequest.statusText & _
"</p>" & VbCrLf
End If
That example does a HTTP GET request but of course you could do a POST
as well and use the same code to deal with the response to a POST request.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
