XML parsing using ASP

Discussion in 'ASP General' started by VK, Sep 30, 2004.

  1. VK

    VK Guest

    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, Sep 30, 2004
    #1
    1. Advertising

  2. 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.
     
    Bob Barrows [MVP], Sep 30, 2004
    #2
    1. Advertising

  3. VK

    Mark Schupp Guest

    Show error message.
    Show xml.responseText

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


    <VK> wrote in message news:%...
    > 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!
     
    Mark Schupp, Sep 30, 2004
    #3
  4. VK

    VK Guest

    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!
     
    VK, Sep 30, 2004
    #4
  5. 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.
     
    Bob Barrows [MVP], Sep 30, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Per Magnus L?vold
    Replies:
    0
    Views:
    1,402
    Per Magnus L?vold
    Nov 15, 2004
  2. Greg Wogan-Browne
    Replies:
    1
    Views:
    828
    Uche Ogbuji
    Jan 28, 2005
  3. Originlabs
    Replies:
    0
    Views:
    459
    Originlabs
    Apr 23, 2008
  4. John Levine
    Replies:
    0
    Views:
    747
    John Levine
    Feb 2, 2012
  5. Erik Wasser
    Replies:
    5
    Views:
    481
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page