I am using XMLTextWriter to serialize a bunch of my objects into HTML (since HTML is basically XML), and all of my objects are able to read/write themselves as XML anyway. The method works great except for one small snag. HTML has some invalid XML such as for a space. The TextWriter always converts this to &nbps;. I can not wrap this in a CDATA tag because the browser will simply ignore the tag, I literally need the XmlTextWriter to leave my & alone.
Share
Have you tried XmlTextWriter.WriteRaw() to write those values?
I’m pretty sure this doesn’t get escaped – not sure how this ties in with the code you’ve got though…