Reputation: 1157
I have the following XDocument
object:
<Field value="<MyTag>BlaBla</MyTag>" />
I want to get the value with the < ; > ; etc..What I'm tried:
string value = myXdocumentObject.Element("Field").Attribute("value").Value;
But value is < MyTag>BlaBla< /MyTag>'
and not < ;MyTag>BlaBla< ;/MyTag& gt;
How can i take the value?
Upvotes: 2
Views: 54
Reputation: 4893
That is default behavior. Value property will decode escaped characters. If you want to have it encoded; you can just re-encode it with HttpUtility.HtmlEncode
var value = HttpUtility.HtmlEncode(myXdocumentObject.Element("Field").Attribute("value").Value);
Upvotes: 4