Manipulating XML REQUEST withing ASP

S

SP

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
 
M

Mark Schupp

What do you get with:

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

SP

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 said:
What do you get with:

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

--
--Mark Schupp


SP said:
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
 
M

Mark Schupp

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 said:
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 said:
What do you get with:

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

--
--Mark Schupp


SP said:
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
 
S

SP

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 said:
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 said:
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 said:
What do you get with:

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

--
--Mark Schupp


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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top