XmlReader.WriteRaw is still escaping '<' and '>'

b65ran

New Member
I'm definitely missing something. I have an XML file that stores HTML snippets, as below:\[code\]<?xml version="1.0" encoding="utf-8"?><presentation> <slide id="1" title="Test Slide 1"> <h1>This is test slide 1.</h1> <p>Information on test slide.</p> </slide> <slide id="2" title="Test Slide 2"> <h2> This is test slide 2.</h2> <p>Information on test slide.</p> </slide> <slide id="3" title="Test Slide 3"> <h3> This is test slide 3.</h3> <p>Information on test slide.</p> </slide></presentation>\[/code\]I'm building a ASP.net form that allows me to edit the contents of the "slides" and then save my changes. In order to do that, first i find the appropriate slide by \[code\]id\[/code\]. Then I remove all the contents of the slide with \[code\]RemoveNodes()\[/code\], and then attempt to write the new contents with \[code\]WriteRaw(contents)\[/code\].\[code\] XDocument xmlDoc = XDocument.Load(filepath); XElement slide = xmlDoc.Descendants("slide").First(el => el.Attribute("id").Value.Equals(id)); slide.RemoveNodes(); using (var writer = slide.CreateWriter()) { // contents are retrieved from a TextBox writer.WriteRaw(contents); } xmlDoc.Save(filepath);\[/code\]The code runs without error. However, when I check the xml file, the \[code\]<\[/code\] and \[code\]>\[/code\] characters for the html tags have been converted to \[code\]<\[/code\] and \[code\]>\[/code\].\[code\]... <slide id="1" title="Test Slide 1"><h1>This is test slide 1.</h1><p>Information on test slide.</p>></slide>...\[/code\]I'm guessing that another object is escaping the characters in the background. \[code\]SaveOptions.DisableFormatting\[/code\] doesn't change the behavior. Can anyone point me in the right direction?
 
Back
Top