Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 16th, 2003, 02:16 PM
Registered User
 
Join Date: Jun 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default special charcters in XML???

Hi, I am trying to read an XML file using XmlDocument.LoadXml() function. This xml has data which contains special characters like ampersand (&). But it fails saying "An error occurred while parsing EntityName. Line 1, position 31."

How can I make this xml string valid before passing to LoadXML() function.

Please advise. Thanks

Pankaj

~~~~Pankaj~~~~

Follow your goals, Means will follow you ---Gandhi---
 
Old July 16th, 2003, 09:04 PM
Registered User
 
Join Date: Jul 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your subject heading "special charcters in XML???" is correct.
The ampersand (&) is a special character in XML. The error message
about entity is apt. An ampersand is a reserved character in XML and it signals the beginning of an entity (in this case, a special character)So, " & " is illegal in XML.

Instead of "&" you need to use the entity reference for the ampersand: &
   So instead of "Proctor & Gamble,"
     you need to use: Proctor & Gamble
 
Old July 17th, 2003, 02:51 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

The joys of HTML. The entity reference for ampersand (&) is:
&

--

Joe
 
Old July 17th, 2003, 02:52 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Even that came out wrongly :). It should be:
&

--

Joe





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in saving arabic charcters from asp sobia Oracle ASP 1 May 11th, 2006 05:54 AM
XML vs. special characters brko C# 1 January 23rd, 2006 11:05 AM
storing special special characters in nvarchar... ACE2084 SQL Server 2000 2 February 9th, 2005 11:45 AM
Special Character mg1966 Classic ASP Databases 2 December 13th, 2004 11:12 AM
XML - Special Character Formatting sean1230 XML 3 February 18th, 2004 05:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.