473,378 Members | 1,152 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Retaining Entities on XmlDocument LoadXml

I'm loading an XmlDocument object from a string using LoadXml. The
string is a well-formed XML fragment (see example) and loads fine,
however there are entities (&) within attribute values. The loader
parses the incoming entities and converts them to their character
references automatically. How would I retain the entity?

Example incoming fragment:

<company name="B &amp; B Electric" />

After loading the fragment gets converted to:

<company name="B & B Electric" />

I want to retain the original
Thanks,
-AJ
Nov 12 '05 #1
1 3006


AJ Brown wrote:
I'm loading an XmlDocument object from a string using LoadXml. The
string is a well-formed XML fragment (see example) and loads fine,
however there are entities (&amp;) within attribute values. The loader
parses the incoming entities and converts them to their character
references automatically. How would I retain the entity?

Example incoming fragment:

<company name="B &amp; B Electric" />

After loading the fragment gets converted to:

<company name="B & B Electric" />


That would not be well-formed. How do you check the output?

If I do

string xmlSnippet = @"<company name=""B &amp; B Electric"" />";
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(xmlSnippet);
Console.WriteLine(xmlDocument.OuterXml);

then the output is

<company name="B &amp; B Electric" />

--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: bheem | last post by:
I have a few questions about DTD ENTITY. I would appreciate any help. 1. Is there any equivalent of this in xsd? Suppose I want to use the same string in multiple places in an xml file, is it...
6
by: Yechezkal Gutfreund | last post by:
I have been using the following code (successfully) to read Xml formated text packets from a TCP stream. The output from the server stream consists of a sequence of well formed Xml documents...
1
by: Martin Honnen | last post by:
With both .NET 1.0 and 1.1 I have found the following strange behaviour where System.Xml.XmlDocument.LoadXml doesn't throw an error when parsing a text node with a character reference to an invalid...
2
by: Dave | last post by:
Hi, Is there an easier way to pull a subset of nodes from one XmlDocument to another? I have the code below but would like to know if there is a more streamlined method. Thanks, Dave ...
2
by: Lupina | last post by:
Hi I want load whole xml file, I try do it in the same way as I did it in windows application. try { XmlDocument myDoc = new XmlDocument();
4
by: Carlos Albert | last post by:
Hello, Would you tell me if there is a way to extract a single node as a new xmldocument? Thanks.
3
by: Dylan Parry | last post by:
Hi, If I create an XML document using: XmlDocument xmldoc = new XmlDocument(); And I start load in some XML using: xmldoc.LoadXml("<root...
2
by: Frantic | last post by:
I'm working on a list of japaneese entities that contain the entity, the unicode hexadecimal code and the xml/sgml entity used for that entity. A unicode document is read into the program, then the...
3
by: peuramaki | last post by:
Hello all, I'm having a bit of a problem with System.Xml.XmlDocument. The scenario is as follows: I receive a dataset containing some data fetched from database. I can retrieve a string...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.