1

I'm creating xml-like mark-up language using System.Xml.XmTextWriter that will be read by a third party app.

In this mark-up language, symbols > and < when inside an element, need to show up as, but the XmlTextWriter converts them to &gt ; and &lt ; (no spaces, I just added those because of formatting on here).

Any ideas on how to prevent this while still working with XmlTextWriter?

andyhasit
  • 14,137
  • 7
  • 49
  • 51

1 Answers1

3

You can output raw XML (no escaping) with the XmlTextWriter.WriteRaw method.

http://msdn.microsoft.com/en-us/library/z7sb8fsy.aspx

Chris Gessler
  • 22,727
  • 7
  • 57
  • 83
  • Chris, I've up-voted your answer because it is a good one (and taught me something I didn't know), but I may have misled you into assuming I needed the output to be valid xml, whereas it's just an xml-like mark-up language (hence the < and <). I've edit my post to clarify that, apologies... – andyhasit Mar 26 '12 at 13:02
  • @AndyHasIt - No problem. If you need an invalid "XML" doc simply use a StringBuilder() to build it. – Chris Gessler Mar 26 '12 at 13:09
  • @AndyHasIt - almost forgot about the WriteRaw method. I've updated my answer. – Chris Gessler Mar 26 '12 at 20:24