Textwriter

M

MDB

Hello all, I have a text writer that is re-formating some of my characters
(& to html &). Is there a way to make it stop doing this? I am new to
xml and textwriters so I am not real sure if I am doing this correctly.
Here is what my code looks like

XmlTextWriter writer = null;
System.IO.TextWriter tw = new StringWriter();
writer = new XmlTextWriter (tw);
writer.Flush();
writer.Formatting = Formatting.None;
writer.WriteStartElement("BODY");
writer.WriteStartElement(objSendType.ToString());

if(strFrom != null){writer.WriteAttributeString("FROM",strFrom);}
if(strTo != null){writer.WriteAttributeString("TO",strTo);}

if(strMessage != null){writer.WriteString(strMessage);}

writer.WriteEndElement();
writer.WriteEndElement();

writer.Close();
 
J

Jon Skeet [C# MVP]

Hello all, I have a text writer that is re-formating some of my characters
(& to html &). Is there a way to make it stop doing this? I am new to
xml and textwriters so I am not real sure if I am doing this correctly.
Here is what my code looks like

XmlTextWriter writer = null;
System.IO.TextWriter tw = new StringWriter();
writer = new XmlTextWriter (tw);
writer.Flush();
writer.Formatting = Formatting.None;
writer.WriteStartElement("BODY");
writer.WriteStartElement(objSendType.ToString());

if(strFrom != null){writer.WriteAttributeString("FROM",strFrom);}
if(strTo != null){writer.WriteAttributeString("TO",strTo);}

if(strMessage != null){writer.WriteString(strMessage);}

writer.WriteEndElement();
writer.WriteEndElement();

writer.Close();

It's meant to do that - it's not an HTML & it's an XML & an
element with content of (say) x & y isn't valid.
 

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