Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8138729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:35:20+00:00 2026-06-06T11:35:20+00:00

I’m definitely missing something. I have an XML file that stores HTML snippets, as

  • 0

I’m definitely missing something. I have an XML file that stores HTML snippets, as below:

<?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>

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 id. Then I remove all the contents of the slide with RemoveNodes(), and then attempt to write the new contents with WriteRaw(contents).

    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);

The code runs without error. However, when I check the xml file, the < and > characters for the html tags have been converted to &lt; and &gt;.

...
  <slide id="1" title="Test Slide 1">&lt;h1&gt;This is test slide 1.&lt;/h1&gt;
&lt;p&gt;Information on test slide.&lt;/p&gt;&gt;</slide>
...

I’m guessing that another object is escaping the characters in the background. SaveOptions.DisableFormatting doesn’t change the behavior. Can anyone point me in the right direction?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:35:21+00:00Added an answer on June 6, 2026 at 11:35 am

    Sorry, but XmlWriter.WriteRaw works on XmlWriters writing to a stream or file but not when populating objects in System.Xml or System.Xml.Linq.
    Use slide.Add(XElement.Parse("<dummy>" + contents + "</dummy>").Nodes()) instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.