473,322 Members | 1,268 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,322 software developers and data experts.

XmlTextReader.Read() and ampersand?

XmlTextReader reader = new XmlTextReader
("c:/downloads/somedata.xml");

while (reader.Read())
{
....etc.
}

I've determined that the problem in the source XML is a
node that contains an attribute that doesn't have the
ampersand encoded as "&"

<item security="Common Stock (Class A, B & C)">

How do I manage this because when the Read() method above
reaches this portion of the XML document, I get a parsing
error. How do I encode "&" prior to the Read() somehow?

Dave.
Nov 12 '05 #1
1 6418
Dave wrote:
I've determined that the problem in the source XML is a
node that contains an attribute that doesn't have the
ampersand encoded as "&amp;"

<item security="Common Stock (Class A, B & C)">

How do I manage this because when the Read() method above
reaches this portion of the XML document, I get a parsing
error. How do I encode "&" prior to the Read() somehow?


No help from XmlReader. XML documents cannot contain unescaped &, full
stop. So before working with this file as XML first escape all & using
non-XML tools, such as regexp. Or better fix application which produces
such non-wellformed XML.
--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog

Nov 12 '05 #2

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

Similar topics

4
by: Meir S. | last post by:
I think the following is a bug in XmlTextReader: I need to process large XMLs, that are typically constructed of many small elements nested in the root element. Each inner element represents a...
2
by: Mitch | last post by:
I have some simple HTML I'm trying to read with the XMLTextReader. As in the MSDS examples, I set up a loop to read each XML node: while (reader.Read()) { switch (reader.NodeType) { case...
5
by: Geoff Bennett | last post by:
While parsing an XML document, my TextReader instance skips nodes. For example, in this fragment: <Person Sex="Male" FirstHomeBuyer="No" YearsInCurrentProfession="14"> <RelatedEntityRef...
5
by: Chris | last post by:
Hi, the docs say : "The Xml-document is not loaded into memory when using XmlTextReader, as opposed to using the DOM where the entire document is loaded in memory" but, when using...
1
by: edi | last post by:
Hi, I have MS .Net Framework v1.1.4322. I have this XML file: <?xml version="1.0" ?> <!--here there are two spaces at the beginning--> <aaa> <a id="1"> <Dept>Finance</Dept>
3
by: prasad | last post by:
Hi, I am using XMLTextReader class to read the xml files. In some cases xml declaration tag might start after space/tab charecters. These kind of files are supported by the browsers and xml dom's...
1
by: RJN | last post by:
Hi I'm using XMLTextReader to parse the contents of XML. I have issues when the xml content itself has some special characters like & ,> etc. <CompanyName>Johnson & Jhonson</CompanyName>...
1
by: SHC | last post by:
Hi all, I did the "Build" on the attached code in my VC++ .NET 2003 - Windows XP Pro PC. On the c:\ screen, I got the following: Microsoft Development Environment An unhandled exception of type...
3
by: Kjeld | last post by:
My scenario: I'm using an XmlTextReader to Deserialize serveral classes from a single xml document. Every class i pass the source stream, containing the xml. Each class subsequently creates an...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.