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

Using XmlTextReader to read unicode characters

I have a unicode XML file that I am trying to read using the .NET
XmlTextReader in C#. How do I read the unicode file? If I try to
using the XmlTextReader.Read() method, it throws an exception.

The exception reads:
The '€' character, hexadecimal value 0x80, cannot begin with a name.
Line 1, position 2.

Any suggestions? I read on Microsoft's website about writing surrogate
pairs, but I can't find any documentation that confirms the
XmlTextReader can handle surrogate pairs.

Nov 17 '05 #1
1 4129


Jordan wrote:
I have a unicode XML file that I am trying to read using the .NET
XmlTextReader in C#. How do I read the unicode file? If I try to
using the XmlTextReader.Read() method, it throws an exception.
What Unicode encoding does that XML file have (e.g. UTF-8 or UTF-16)?
How do you know it is Unicode?
Is there an XML declaration (e.g. <?xml version="1.0"
encoding="UTF-8"?>) at the beginning? Is there a BOM (byte order mark)?
How do you create the XmlTextReader, simply with
new XmlTextReader("file.xml")
?
The exception reads:
The '€' character, hexadecimal value 0x80, cannot begin with a name.
Line 1, position 2.


Maybe the XML is not properly encoded? How do the first lines of the XML
file look?
What happens when you load the file with the IE browser? Does that give
a parse error too?

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 17 '05 #2

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

Similar topics

3
by: Michael | last post by:
http://support.microsoft.com/default.aspx?scid=kb;en-us;815658 The page above solved all of my problems with one exception. When the file has strange data in it, possibly Japanese, I get the...
1
by: aevans1108 | last post by:
Greetings All If this is the wrong place to post this question, please give me a push in the right direction. Thanks. I know there has to be a simpler way to do this, but this is as simple a...
2
by: Q | last post by:
I am feeding XmlTextReader a URL that returns the XML that then gets parsed. The URL forms a query that affects how much data is returned in XML but not the format of the data. The problem is...
3
by: Brad Wood | last post by:
I have an XML document in a file (e:\bobo.xml) saved using unicode encoding with declaration: <?xml version="1.0" encoding="UTF-16"?> I can load that file into an XmlTextReader and read it just...
1
by: Michael Hodges | last post by:
http://support.microsoft.com/default.aspx?scid=kb;en-us;815658 The page above solved all of my problems with one exception. When the file has strange data in it, possibly Japanese, I get the...
3
by: Goran Djuranovic | last post by:
Hi all, I ran into a problem where my XMLTextReader fails on .Read() when I have "<" character in one of the attribute's values. What I am trying to do is replace illegal characters ("<", "&" ,...
5
by: midhunmathe | last post by:
Hello, I get an error #', hexadecimal value 0x07, is an invalid character. Line 2, position 6358. on the XMLTextReader.Read() call on a particular node of my XML document. I need this data...
0
by: =?Utf-8?B?Slc=?= | last post by:
I read some advice given to someone here to use RegEx to get around invalid XML characters. Goran Djuranovic asked the question in 1-21-2007. The advice was given by Keith Patrick and Goran...
1
by: Mudcat | last post by:
In short what I'm trying to do is read a document using an xml parser and then upload that data back into a database. I've got the code more or less completed using xml.etree.ElementTree for the...
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: 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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.