Ideas needed: encoding an XML document so that it can be passed in a PARAM attribute of an OBJECT t

N

None

I want to pass a serialized DataSet to a .NET WinForm control on a web page.
I am using a PARAM attribute in the OBJECT tag to pass the serialized string
to the control as follows:

<PARAM name="doc" value="<?xml..........(etc)">

The problem is that the string (the XML document) contains double-quote
characters and that is bad.

What's the best way to encode the string so that it can be succesfully
passed? I can use Base64 encoding but then I have to deal with byte arrays,
performance issues, etc. Is there an easier/better way?
 
J

Jon Skeet

None said:
I want to pass a serialized DataSet to a .NET WinForm control on a web page.
I am using a PARAM attribute in the OBJECT tag to pass the serialized string
to the control as follows:

<PARAM name="doc" value="<?xml..........(etc)">

The problem is that the string (the XML document) contains double-quote
characters and that is bad.

What's the best way to encode the string so that it can be succesfully
passed? I can use Base64 encoding but then I have to deal with byte arrays,
performance issues, etc. Is there an easier/better way?

Either convert to UTF-8 encoded bytes, then base64 encode, or manually
escape all the characters you don't want to be literally embedded, eg
by using \l for <, \g for >, \q for ", \a for ', \r for carriage
return, etc, and \\ for \. This will almost certainly be more work, but
*may* perform better (there's no guarantee though). Are you sure
performance is actually an issue here? I suggest you try the base64 way
first, and see whether that's actually too slow.
 
N

Norman Harebottle III

If the data is static anyway, why not read it from memory on the server or
from a static xml file. No conversion neccessary.

Norman
 

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

Top