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

  • Home
  • SEARCH
  • 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 7984037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:08:30+00:00 2026-06-04T11:08:30+00:00

I’m having problems while attaching some strings to some XML nodes. To explain this

  • 0

I’m having problems while attaching some strings to some XML nodes.
To explain this better I’ve made a simple example… just imagine that I have this XML code:

<song>
    <title>
        Surfin&#39; USA
    </title>
</song>

Please notice that instead of simply writing “Surfin’ USA” I’m expressly using &#39; instead of the single quote character.
The XML code is valid – or at least it has been considered valid by some tools I have found and tested online.

My Problem is that when I try to put that string into a XmlText object, this way:

Dim xmlDoc As New XmlDocument()
Dim xmlMyText As XmlText


xmlMyText = xmlDoc.CreateTextNode("Surfin&#39; USA")

I would expect to have the very same string value inside the XmlText object, but instead it’s getting a slightly different value:

MsgBox(xmlMyText.OuterXml)  ' OUTPUTS: Surfin&amp;39; USA

In short, the ampersand symbol gets converted into &amp; because AFAIK “an ampersand cannot be left unescaped”. But in my opinion in this case it is not unescaped because it is used in conjunction with #39 and the semicolon, am I wrong ?

Could you help me and explain how could I avoid this conversion?
Thank you very much for your time and help

  • 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-04T11:08:32+00:00Added an answer on June 4, 2026 at 11:08 am

    It is a common problem to have a mismatch between the number of escaping passes you have sent in and how many you are trying to use on the data being output.

    Here the OuterXml is doing exactly what it is designed to do: giving you the data it provided in an escaped (XML as stored) form. This is a good thing, because if you save this XML and then load it back into an XML document, you can navigate to the node and ask for .InnerText() on the node and get the original value, which is what you would expect. For it to do otherwise would break the contract.

    However, by asking for OuterXml (which returns markup) instead of getting the InnerText value (which returns stored data), you are “off by one” on the escaping sequence. You can manually run an unescaping on the data or use the .InnerText() to automatically convert back to your source data.

    using System;
    using System.Text;
    using System.Collections.Generic;
    using System.Linq;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Xml;       
    
    namespace TestProject1
    {
        [TestClass]
        public class UnitTest1
        {
            private const string testString = "Surfin&#39; USA";
            [TestMethod]
            public void TestMethod1()
            {
                XmlDocument xmlDoc = new XmlDocument();
                XmlText xmlMyText;
    
                xmlMyText = xmlDoc.CreateTextNode(testString);
    
                Assert.AreEqual(testString, xmlMyText.InnerText);
    
            }
        }
    }
    

    This unit test passes. Please forgive my use of C#, but that is what my fingers type.

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

Sidebar

Related Questions

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
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
In my XML file chapters tag has more chapter tag.i need to display chapters

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.