Guest User

Untitled

a guest
Aug 17th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. How to prevent XElement from decoding character entity references
  2. string originalXML = @"<Description><data>Mark's Data</data></Description>"; //for illustration purposes only
  3. string encodedApostrophe = originalXML.Replace("'", "&#39;");
  4. XElement xe = XElement.Parse(encodedApostrophe);
  5.  
  6. originalXML.Replace("'", "&#39;")
  7.  
  8. XElement xe = XElement.Parse(originalXML);
  9.  
  10. var data = xe.Element("data");
  11.  
  12. data.Value = data.Value.Replace("'", "&#39;");
Add Comment
Please, Sign In to add comment