Manipulating XML REQUEST withing ASP

Discussion in 'ASP General' started by SP, Aug 3, 2005.

  1. SP

    SP Guest

    Hi I have a problem with a customer's XML being submitting to me in a
    non-well-format XML.
    They said that there are 18 other partners who has been able to tweak the
    XML to make it work.
    So I guess here is my question, in ASP, when working with XML, how do you
    handle non-well-formed XML documents on the "listener" response side?

    Here's the scenerio:

    Customer post XML Data to us (non-well-formed XML)
    ie: <sites>
    <mytag1>http://sonny.com/</mytag1>
    <mytag2><![CDATA[http://google.com?search=hellow+world&language=EN]]></mytag2>
    <mytag3>http://mysite.com/helloworld/?myvar1=123&myvar2=abc</mytag3>
    </sites>

    Looking at the XML data above the mytag1 and mytag2 are fully W3C XML
    conformed XML syntax, however the mytag3 is NOT. there are 2 tags in XML
    that are considered illegal characters in XML data, the "&" and the "<". In
    our case it's the "&" that's giving us grief.

    Ok continue on, the customer sends this messed up format to me and I open it
    up with the MSXML DOM object and it craps out. Because it can't load the
    REQUEST XML.

    Anyone know how to PULL the REQUEST value to a STRING variable? here are
    some sample codes I've tried.
    sample 1.
    Set X = server.createobject("Microsoft.XMLDOM")
    X.async = False
    X.Load(REQUEST)
    strXML = X.xml
    Response.ContentType="text/xml"
    Response.Write strXML

    Sample 2.
    strXML = cstr(REQUEST)
    Response.ContentType="text/xml"
    Response.Write strXML

    Both doesn't work with the non-well-formed XML sent, Sample 2 doesn't work
    regardless, however Sample 1 does work with a well structured XML document.
    Anyone know how I can pull the XML from the REQUEST so that I can manipulate
    the string and format it so that it is parsable by the XMLDOM?

    Thanks,

    Sonny
    SP, Aug 3, 2005
    #1
    1. Advertising

  2. SP

    Mark Schupp Guest

    What do you get with:

    Response.write Server.HTMLEncode(Request.Form) or Response.write
    Server.HTMLEncode(Request.QueryString)

    --
    --Mark Schupp


    "SP" <> wrote in message
    news:%23P5UB%...
    > Hi I have a problem with a customer's XML being submitting to me in a
    > non-well-format XML.
    > They said that there are 18 other partners who has been able to tweak the
    > XML to make it work.
    > So I guess here is my question, in ASP, when working with XML, how do you
    > handle non-well-formed XML documents on the "listener" response side?
    >
    > Here's the scenerio:
    >
    > Customer post XML Data to us (non-well-formed XML)
    > ie: <sites>
    > <mytag1>http://sonny.com/</mytag1>
    >
    > <mytag2><![CDATA[http://google.com?search=hellow+world&language=EN]]></mytag2>
    > <mytag3>http://mysite.com/helloworld/?myvar1=123&myvar2=abc</mytag3>
    > </sites>
    >
    > Looking at the XML data above the mytag1 and mytag2 are fully W3C XML
    > conformed XML syntax, however the mytag3 is NOT. there are 2 tags in XML
    > that are considered illegal characters in XML data, the "&" and the "<".
    > In our case it's the "&" that's giving us grief.
    >
    > Ok continue on, the customer sends this messed up format to me and I open
    > it up with the MSXML DOM object and it craps out. Because it can't load
    > the REQUEST XML.
    >
    > Anyone know how to PULL the REQUEST value to a STRING variable? here are
    > some sample codes I've tried.
    > sample 1.
    > Set X = server.createobject("Microsoft.XMLDOM")
    > X.async = False
    > X.Load(REQUEST)
    > strXML = X.xml
    > Response.ContentType="text/xml"
    > Response.Write strXML
    >
    > Sample 2.
    > strXML = cstr(REQUEST)
    > Response.ContentType="text/xml"
    > Response.Write strXML
    >
    > Both doesn't work with the non-well-formed XML sent, Sample 2 doesn't work
    > regardless, however Sample 1 does work with a well structured XML
    > document.
    > Anyone know how I can pull the XML from the REQUEST so that I can
    > manipulate the string and format it so that it is parsable by the XMLDOM?
    >
    > Thanks,
    >
    > Sonny
    >
    Mark Schupp, Aug 3, 2005
    #2
    1. Advertising

  3. SP

    SP Guest

    Nothing gets returned back.
    I've added the below to make sure that the page was reached and sure enough
    only the attached string was returned... no REQUEST Value returned.

    Response.write Server.HTMLEncode(Request.Form) & " NADDA FORM"
    Response.write Server.HTMLEncode(Request.QueryString) & " NADDA QSTRING"



    "Mark Schupp" <> wrote in message
    news:...
    > What do you get with:
    >
    > Response.write Server.HTMLEncode(Request.Form) or Response.write
    > Server.HTMLEncode(Request.QueryString)
    >
    > --
    > --Mark Schupp
    >
    >
    > "SP" <> wrote in message
    > news:%23P5UB%...
    >> Hi I have a problem with a customer's XML being submitting to me in a
    >> non-well-format XML.
    >> They said that there are 18 other partners who has been able to tweak the
    >> XML to make it work.
    >> So I guess here is my question, in ASP, when working with XML, how do you
    >> handle non-well-formed XML documents on the "listener" response side?
    >>
    >> Here's the scenerio:
    >>
    >> Customer post XML Data to us (non-well-formed XML)
    >> ie: <sites>
    >> <mytag1>http://sonny.com/</mytag1>
    >>
    >> <mytag2><![CDATA[http://google.com?search=hellow+world&language=EN]]></mytag2>
    >> <mytag3>http://mysite.com/helloworld/?myvar1=123&myvar2=abc</mytag3>
    >> </sites>
    >>
    >> Looking at the XML data above the mytag1 and mytag2 are fully W3C XML
    >> conformed XML syntax, however the mytag3 is NOT. there are 2 tags in XML
    >> that are considered illegal characters in XML data, the "&" and the "<".
    >> In our case it's the "&" that's giving us grief.
    >>
    >> Ok continue on, the customer sends this messed up format to me and I open
    >> it up with the MSXML DOM object and it craps out. Because it can't load
    >> the REQUEST XML.
    >>
    >> Anyone know how to PULL the REQUEST value to a STRING variable? here are
    >> some sample codes I've tried.
    >> sample 1.
    >> Set X = server.createobject("Microsoft.XMLDOM")
    >> X.async = False
    >> X.Load(REQUEST)
    >> strXML = X.xml
    >> Response.ContentType="text/xml"
    >> Response.Write strXML
    >>
    >> Sample 2.
    >> strXML = cstr(REQUEST)
    >> Response.ContentType="text/xml"
    >> Response.Write strXML
    >>
    >> Both doesn't work with the non-well-formed XML sent, Sample 2 doesn't
    >> work regardless, however Sample 1 does work with a well structured XML
    >> document.
    >> Anyone know how I can pull the XML from the REQUEST so that I can
    >> manipulate the string and format it so that it is parsable by the XMLDOM?
    >>
    >> Thanks,
    >>
    >> Sonny
    >>

    >
    >
    SP, Aug 4, 2005
    #3
  4. SP

    Mark Schupp Guest

    Maybe you can open the request object with an ADODB stream object. Otherwise
    you will probably have to use Request.BinaryRead to get the data. You might
    also have a look at the soap toolkit to see if it can recover badly formed
    XML.

    --
    --Mark Schupp


    "SP" <> wrote in message
    news:...
    > Nothing gets returned back.
    > I've added the below to make sure that the page was reached and sure
    > enough only the attached string was returned... no REQUEST Value returned.
    >
    > Response.write Server.HTMLEncode(Request.Form) & " NADDA FORM"
    > Response.write Server.HTMLEncode(Request.QueryString) & " NADDA QSTRING"
    >
    >
    >
    > "Mark Schupp" <> wrote in message
    > news:...
    >> What do you get with:
    >>
    >> Response.write Server.HTMLEncode(Request.Form) or Response.write
    >> Server.HTMLEncode(Request.QueryString)
    >>
    >> --
    >> --Mark Schupp
    >>
    >>
    >> "SP" <> wrote in message
    >> news:%23P5UB%...
    >>> Hi I have a problem with a customer's XML being submitting to me in a
    >>> non-well-format XML.
    >>> They said that there are 18 other partners who has been able to tweak
    >>> the XML to make it work.
    >>> So I guess here is my question, in ASP, when working with XML, how do
    >>> you handle non-well-formed XML documents on the "listener" response
    >>> side?
    >>>
    >>> Here's the scenerio:
    >>>
    >>> Customer post XML Data to us (non-well-formed XML)
    >>> ie: <sites>
    >>> <mytag1>http://sonny.com/</mytag1>
    >>>
    >>> <mytag2><![CDATA[http://google.com?search=hellow+world&language=EN]]></mytag2>
    >>> <mytag3>http://mysite.com/helloworld/?myvar1=123&myvar2=abc</mytag3>
    >>> </sites>
    >>>
    >>> Looking at the XML data above the mytag1 and mytag2 are fully W3C XML
    >>> conformed XML syntax, however the mytag3 is NOT. there are 2 tags in XML
    >>> that are considered illegal characters in XML data, the "&" and the "<".
    >>> In our case it's the "&" that's giving us grief.
    >>>
    >>> Ok continue on, the customer sends this messed up format to me and I
    >>> open it up with the MSXML DOM object and it craps out. Because it can't
    >>> load the REQUEST XML.
    >>>
    >>> Anyone know how to PULL the REQUEST value to a STRING variable? here are
    >>> some sample codes I've tried.
    >>> sample 1.
    >>> Set X = server.createobject("Microsoft.XMLDOM")
    >>> X.async = False
    >>> X.Load(REQUEST)
    >>> strXML = X.xml
    >>> Response.ContentType="text/xml"
    >>> Response.Write strXML
    >>>
    >>> Sample 2.
    >>> strXML = cstr(REQUEST)
    >>> Response.ContentType="text/xml"
    >>> Response.Write strXML
    >>>
    >>> Both doesn't work with the non-well-formed XML sent, Sample 2 doesn't
    >>> work regardless, however Sample 1 does work with a well structured XML
    >>> document.
    >>> Anyone know how I can pull the XML from the REQUEST so that I can
    >>> manipulate the string and format it so that it is parsable by the
    >>> XMLDOM?
    >>>
    >>> Thanks,
    >>>
    >>> Sonny
    >>>

    >>
    >>

    >
    >
    Mark Schupp, Aug 4, 2005
    #4
  5. SP

    SP Guest

    Mark Thanks for the help, I was able to overcome this obstacle by using the
    Request.BinaryRead then using my own function to convert Bytes to ASCII.
    Here's my code.

    lngByteSize = Request.TotalBytes
    s = BytesToText(Request.BinaryRead(lngByteSize))

    Function BytesToText(strBytes)
    Dim lngLength, lngIndex, lngAsciiCode
    strAsciiText lngLength = LenB(strBytes)
    For lngIndex = 1 To lngLength
    lngAsciiCode = AscB(MidB(strBytes, lngIndex, 1))
    strAsciiText = strAsciiText & Chr(lngAsciiCode)
    Next
    BytesToText = strAsciiText
    End Function



    "Mark Schupp" <> wrote in message
    news:%...
    > Maybe you can open the request object with an ADODB stream object.
    > Otherwise you will probably have to use Request.BinaryRead to get the
    > data. You might also have a look at the soap toolkit to see if it can
    > recover badly formed XML.
    >
    > --
    > --Mark Schupp
    >
    >
    > "SP" <> wrote in message
    > news:...
    >> Nothing gets returned back.
    >> I've added the below to make sure that the page was reached and sure
    >> enough only the attached string was returned... no REQUEST Value
    >> returned.
    >>
    >> Response.write Server.HTMLEncode(Request.Form) & " NADDA FORM"
    >> Response.write Server.HTMLEncode(Request.QueryString) & " NADDA QSTRING"
    >>
    >>
    >>
    >> "Mark Schupp" <> wrote in message
    >> news:...
    >>> What do you get with:
    >>>
    >>> Response.write Server.HTMLEncode(Request.Form) or Response.write
    >>> Server.HTMLEncode(Request.QueryString)
    >>>
    >>> --
    >>> --Mark Schupp
    >>>
    >>>
    >>> "SP" <> wrote in message
    >>> news:%23P5UB%...
    >>>> Hi I have a problem with a customer's XML being submitting to me in a
    >>>> non-well-format XML.
    >>>> They said that there are 18 other partners who has been able to tweak
    >>>> the XML to make it work.
    >>>> So I guess here is my question, in ASP, when working with XML, how do
    >>>> you handle non-well-formed XML documents on the "listener" response
    >>>> side?
    >>>>
    >>>> Here's the scenerio:
    >>>>
    >>>> Customer post XML Data to us (non-well-formed XML)
    >>>> ie: <sites>
    >>>> <mytag1>http://sonny.com/</mytag1>
    >>>>
    >>>> <mytag2><![CDATA[http://google.com?search=hellow+world&language=EN]]></mytag2>
    >>>> <mytag3>http://mysite.com/helloworld/?myvar1=123&myvar2=abc</mytag3>
    >>>> </sites>
    >>>>
    >>>> Looking at the XML data above the mytag1 and mytag2 are fully W3C XML
    >>>> conformed XML syntax, however the mytag3 is NOT. there are 2 tags in
    >>>> XML that are considered illegal characters in XML data, the "&" and the
    >>>> "<". In our case it's the "&" that's giving us grief.
    >>>>
    >>>> Ok continue on, the customer sends this messed up format to me and I
    >>>> open it up with the MSXML DOM object and it craps out. Because it can't
    >>>> load the REQUEST XML.
    >>>>
    >>>> Anyone know how to PULL the REQUEST value to a STRING variable? here
    >>>> are some sample codes I've tried.
    >>>> sample 1.
    >>>> Set X = server.createobject("Microsoft.XMLDOM")
    >>>> X.async = False
    >>>> X.Load(REQUEST)
    >>>> strXML = X.xml
    >>>> Response.ContentType="text/xml"
    >>>> Response.Write strXML
    >>>>
    >>>> Sample 2.
    >>>> strXML = cstr(REQUEST)
    >>>> Response.ContentType="text/xml"
    >>>> Response.Write strXML
    >>>>
    >>>> Both doesn't work with the non-well-formed XML sent, Sample 2 doesn't
    >>>> work regardless, however Sample 1 does work with a well structured XML
    >>>> document.
    >>>> Anyone know how I can pull the XML from the REQUEST so that I can
    >>>> manipulate the string and format it so that it is parsable by the
    >>>> XMLDOM?
    >>>>
    >>>> Thanks,
    >>>>
    >>>> Sonny
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
    SP, Aug 4, 2005
    #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. Chris Ericoli
    Replies:
    0
    Views:
    477
    Chris Ericoli
    Oct 30, 2003
  2. =?Utf-8?B?dHRob21wc29uMjAwNw==?=

    Options for viewing word docs and editing from withing asp.net

    =?Utf-8?B?dHRob21wc29uMjAwNw==?=, Sep 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    327
    =?Utf-8?B?dHRob21wc29uMjAwNw==?=
    Sep 20, 2004
  3. Replies:
    1
    Views:
    311
    =?Utf-8?B?Q3VydF9DIFtNVlBd?=
    Sep 9, 2005
  4. Karin Bjerregaard

    JSP expression withing an XML attribute?

    Karin Bjerregaard, Sep 2, 2003, in forum: XML
    Replies:
    0
    Views:
    425
    Karin Bjerregaard
    Sep 2, 2003
  5. Chris Ericoli

    Problems with asp:placeholder nested withing datalist

    Chris Ericoli, Oct 30, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    117
    Quicky
    Oct 31, 2003
Loading...

Share This Page