For Programmers: Free Programming Magazines  


Home > Archive > ASP > September 2004 > XML parsing using ASP









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author XML parsing using ASP
VK

2004-09-30, 3:55 pm

Dear All:

I have an issue trying to parse response from xml document, for that
matter I don't receive back response.

I am trying to integrate UPS e-commerce online tool into our web site,
this tool calcuates the rates and services and returns back all the
different shipping rates.

Below is the code trying to display the return response.

==============
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "POST", "https://wwwcie.ups.com/ups.app/xml/rate", False
xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xml.Send xmltext
Response.Write xml.responseText
Dim xmldom
Set xmldom = Server.CreateObject("Microsoft.XMLDOM")
xmldom.async = false
xmldom.loadxml(xml.responseText)

(xmltext - has the XML string to send )

When I try to set
Set root = xmldom.documentElement

and try to display the child nodes - it comes back with error message.

Any help would be appreciated.

Many thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Bob Barrows [MVP]

2004-09-30, 3:55 pm

VK wrote:
> Dear All:
>
> I have an issue trying to parse response from xml document, for that
> matter I don't receive back response.
>
> I am trying to integrate UPS e-commerce online tool into our web site,
> this tool calcuates the rates and services and returns back all the
> different shipping rates.
>
> Below is the code trying to display the return response.
>
> ==============
> Set xml = Server.CreateObject("Microsoft.XMLHTTP")


You should use "Microsoft.ServerXMLHTTP" in server-side code.I would also
suggest using "msxm2" instead of "Microsoft" to avoid version problems.

> xml.Open "POST", "https://wwwcie.ups.com/ups.app/xml/rate", False
> xml.setRequestHeader "Content-Type",
> "application/x-www-form-urlencoded" xml.Send xmltext
> Response.Write xml.responseText
> Dim xmldom
> Set xmldom = Server.CreateObject("Microsoft.XMLDOM")
> xmldom.async = false
> xmldom.loadxml(xml.responseText)
>
> (xmltext - has the XML string to send )
>
> When I try to set
> Set root = xmldom.documentElement
>
> and try to display the child nodes - it comes back with error message.


????
Are we supposed to look up your error message in our crystal ball?

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Mark Schupp

2004-09-30, 3:55 pm

Show error message.
Show xml.responseText

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com


<VK> wrote in message news:%23QzvQxupEHA.1952@TK2MSFTNGP12.phx.gbl...
> Dear All:
>
> I have an issue trying to parse response from xml document, for that
> matter I don't receive back response.
>
> I am trying to integrate UPS e-commerce online tool into our web site,
> this tool calcuates the rates and services and returns back all the
> different shipping rates.
>
> Below is the code trying to display the return response.
>
> ==============
> Set xml = Server.CreateObject("Microsoft.XMLHTTP")
> xml.Open "POST", "https://wwwcie.ups.com/ups.app/xml/rate", False
> xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
> xml.Send xmltext
> Response.Write xml.responseText
> Dim xmldom
> Set xmldom = Server.CreateObject("Microsoft.XMLDOM")
> xmldom.async = false
> xmldom.loadxml(xml.responseText)
>
> (xmltext - has the XML string to send )
>
> When I try to set
> Set root = xmldom.documentElement
>
> and try to display the child nodes - it comes back with error message.
>
> Any help would be appreciated.
>
> Many thanks.
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



VK

2004-09-30, 3:55 pm

Here is the code:
set node = xmldom.documentElement
For Each child In node.childNodes
response.write child.Nodename & ": (" & child.Text & ")" & "<BR>"
next

Error message:
Microsoft VBScript runtime error '800a01a8'

Object required


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Bob Barrows [MVP]

2004-09-30, 8:55 pm

VK wrote:
> Here is the code:
> set node = xmldom.documentElement
> For Each child In node.childNodes
> response.write child.Nodename & ": (" & child.Text & ")" & "<BR>"
> next
>
> Error message:
> Microsoft VBScript runtime error '800a01a8'
>
> Object required
>
>

Instead of

xmldom.loadxml(xml.responseText)

do this:

bStatus = xmldom.loadxml(xml.responseText)
if not bStatus then
Set xPE = xmldom.parseError
strMessage = "errorCode = " & xPE.errorCode & "<BR>"
strMessage = strMessage & "reason = " & xPE.reason & "<BR>"
strMessage = strMessage & "Line = " & xPE.Line & "<BR>"
strMessage = strMessage & "linepos = " & xPE.linepos & "<BR>"
strMessage = strMessage & "filepos = " & xPE.filepos & "<BR>"
strMessage = strMessage & "srcText = " & xPE.srcText & "<BR>"
Response.Write strMessage
Response.End
end if

Alternatively, there IS a ResponseXML property which can be used:

Set xmldom=xml.responseXML

Note: If the response was generated by an Active Server Pages (ASP) page and
the Multipurpose Internet Mail Extension (MIME) type was not correctly set
to "text/xml" using the ASP method Response.ContentType, responseXML will be
empty.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com