I have string like this
"<root><text>My test is > & < </text></root>"
Actually this is correct xml, except &, <, > symbols.
I need to convert it to <root><text>My test is > & < </text></root> before I convert it with XElement.Parse(str);
How to make this conversion?
This is nigh-on impossible to achieve reliably. You should correct this issue at source. If you control the system that is inserting the “My test is > & < ” string, then you should escape this string before inserting it.
HttpUtility.HtmlEncodeis a reasonable way of doing that.