C#: Sanitize XML text values with XmlTextWriter? -
I serial some data and continue using XmlTextWriter
Many fields are based on user input (example username). Today I use the WriteElementString
method of XmlTextWriter
.
My question is: The second parameter of WriteElementString
is the text value written in writing. How can I do this before I write?
An example code:
XmlTextWriter author = new XML RemoteWriter ("filename.xml", null); Author.WriteStartElement ("user"); Author. Write element string ("username", InputUser name); Author. Write element string ("email", input email); Writer.WriteEndElement (); Writer.Close ();
The variables are inputUserName
and inputEmail
are user inputs, and I want to save them / save them before writing them.
What is the best way to achieve this?
What exactly do you want to avoid there? To avoid all WriteElementString
will be required by XML already (i.e. & amp;
-> & amp; amp;
,
-> & lt;
, etc.)
Comments
Post a Comment