Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP General (http://www.velocityreviews.com/forums/f65-asp-general.html)
-   -   Manipulating XML REQUEST withing ASP (http://www.velocityreviews.com/forums/t799317-manipulating-xml-request-withing-asp.html)

SP 08-03-2005 09:08 PM

Manipulating XML REQUEST withing ASP
 
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 08-03-2005 10:40 PM

Re: Manipulating XML REQUEST withing ASP
 
What do you get with:

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

--
--Mark Schupp


"SP" <sphimmasone@thealliedgrp.com> wrote in message
news:%23P5UB%23GmFHA.2156@TK2MSFTNGP14.phx.gbl...
> 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 08-04-2005 01:19 PM

Re: Manipulating XML REQUEST withing ASP
 
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" <notvalid@email.net> wrote in message
news:uyAsKyHmFHA.4000@TK2MSFTNGP12.phx.gbl...
> What do you get with:
>
> Response.write Server.HTMLEncode(Request.Form) or Response.write
> Server.HTMLEncode(Request.QueryString)
>
> --
> --Mark Schupp
>
>
> "SP" <sphimmasone@thealliedgrp.com> wrote in message
> news:%23P5UB%23GmFHA.2156@TK2MSFTNGP14.phx.gbl...
>> 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 08-04-2005 03:00 PM

Re: Manipulating XML REQUEST withing ASP
 
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" <sphimmasone@thealliedgrp.com> wrote in message
news:eLFIacPmFHA.1044@tk2msftngp13.phx.gbl...
> 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" <notvalid@email.net> wrote in message
> news:uyAsKyHmFHA.4000@TK2MSFTNGP12.phx.gbl...
>> What do you get with:
>>
>> Response.write Server.HTMLEncode(Request.Form) or Response.write
>> Server.HTMLEncode(Request.QueryString)
>>
>> --
>> --Mark Schupp
>>
>>
>> "SP" <sphimmasone@thealliedgrp.com> wrote in message
>> news:%23P5UB%23GmFHA.2156@TK2MSFTNGP14.phx.gbl...
>>> 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 08-04-2005 04:08 PM

Re: Manipulating XML REQUEST withing ASP
 
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" <notvalid@email.net> wrote in message
news:%234WaEXQmFHA.3816@tk2msftngp13.phx.gbl...
> 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" <sphimmasone@thealliedgrp.com> wrote in message
> news:eLFIacPmFHA.1044@tk2msftngp13.phx.gbl...
>> 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" <notvalid@email.net> wrote in message
>> news:uyAsKyHmFHA.4000@TK2MSFTNGP12.phx.gbl...
>>> What do you get with:
>>>
>>> Response.write Server.HTMLEncode(Request.Form) or Response.write
>>> Server.HTMLEncode(Request.QueryString)
>>>
>>> --
>>> --Mark Schupp
>>>
>>>
>>> "SP" <sphimmasone@thealliedgrp.com> wrote in message
>>> news:%23P5UB%23GmFHA.2156@TK2MSFTNGP14.phx.gbl...
>>>> 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
>>>>
>>>
>>>

>>
>>

>
>





All times are GMT. The time now is 04:34 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57