In my application I'm using XAttribute.SetValue(...) to set the value of an xml-attribute. The value is provided by the user.
I have the following methode to set the attribute-value:
private void SetValue(XAttribute attribute, string input)
{
attribute.SetValue(input);
}
If the input is Hello "World" then the value of the attribute is: Hello "World"
This is what I've expected.
If the input is already "masked" like Hello "World" then the value of the attribute is: Hello "World"
That's not correct.
Is there a way to avoid this conversion?
You can not stop
SetValueencoding characters such as&to entity codes. So, to avoid them being double encoded, you can make sure your input is not encoded to start with. You can do this using:System.Net.WebUtility.HtmlDocode(input)Or, if you have a reference to
System.Webalready,System.Web.HttpUtility.HtmlDecode(input)