473,699 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlTextReader, unicode problem, help?

http://support.microsoft.com/default...b;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 following error:

System.Xml.XmlE xception: '☼', hexadecimal value 0x0F, is an invalid
character. Line 8, position 18.
at System.Xml.XmlS canner.ScanCont ent()
at System.Xml.XmlT extReader.Parse BeginTagExpandC harEntities()
at System.Xml.XmlT extReader.Read( )
at main(Int32 argc, SByte** argv) in
c:\work\xml_rea der\xml_reader. cpp:line 74

This error comes from while (reader->Read()) command, so although I have
#define _UNICODE and changed my char to wchar_t, still getting the error.

Leads me to believe the XmlTextReader is not set up to read unicode.

How would I fix this?

Many, many thanks for your help!!! <Exasperated>
Nov 12 '05 #1
3 2896
Michael wrote:
http://support.microsoft.com/default...b;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 following error:

System.Xml.XmlE xception: '☼', hexadecimal value 0x0F, is an invalid
character. Line 8, position 18.


I can't reproduce the problem. Can you provide full repro - XML document
and your xml_reader.cpp.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2

XML file
---------------
<rdcData version="1.0" target="Search" >
<entity type="O" subtype="NC" id="86">
<header>
<PI>128818</PI>
</header>
<content>
<property id="178396">
<currValue>oy~~ `g</currValue>
<validFrom>1000 0101</validFrom>
</property>
<property id="178392">
<currValue>oy~~ `g</currValue>
<validFrom>1000 0101</validFrom>
</property>
<property id="178402">
<currValue>~y *</currValue>
<validFrom>1999 0212</validFrom>
</property>
<property id="178408">
<currValue>1338 62</currValue>
<validFrom>1000 0101</validFrom>
</property>
<property id="178507">
<currValue>No t categorised</currValue>
</property>
</content>
</entity>
</rdcData>
Microsoft Visual Studio .NET C++ program
(Managed C++ application)
-------------------------------------
#define _UNICODE

#include "stdafx.h"
#include <ctime>
#include <iostream>
using std::cerr;
using std::cout;
using std::endl;
using std::ios;

#include <fstream>
using std::ifstream;
using std::ofstream;

#include <tchar.h>
#include <stdio.h>
#include <stdlib.h>

#using <mscorlib.dll >
#using <System.xml.dll >

using namespace System;
using namespace System::Xml;

void _tmain(int argc, _TCHAR* argv[])
{
if (argc != 2)
{
printf("Usage: xml_reader <filename>\n" );
exit(0);
}

XmlTextReader* reader = new XmlTextReader(a rgv[1]);

try
{
while(reader->Read())
{
switch(reader->NodeType)
{
case XmlNodeType::El ement:
printf("element = %s %s\n",reader->Name,reader->Value);
while (reader->MoveToNextAttr ibute()) // Read the attributes.
{
printf(" Next %s %s\n", reader->Name, reader->Value);
}
break;
case XmlNodeType::Te xt:
printf("text = %s\n",reader->Value);
break;
default:
break;
}

}
}
catch(Exception *pe)
{
printf("%s\n",p e->ToString());
}
}
----------------------
I believe this is the offending line:
<currValue>oy~~ `g</currValue>
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3
This is an invalid XML character according the the valid char range.
[2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] |
[#xE000-#xFFFD] | [#x10000-#x10FFFF] /* any Unicode character, excluding the
surrogate blocks, FFFE, and FFFF. */
See http://www.w3.org/TR/REC-xml/#charsets

Thanks. Mark

"Michael" <mi********@hot mail.com> wrote in message
news:44******** *************** ***@posting.goo gle.com...
http://support.microsoft.com/default...b;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 following error:

System.Xml.XmlE xception: '☼', hexadecimal value 0x0F, is an invalid
character. Line 8, position 18.
at System.Xml.XmlS canner.ScanCont ent()
at System.Xml.XmlT extReader.Parse BeginTagExpandC harEntities()
at System.Xml.XmlT extReader.Read( )
at main(Int32 argc, SByte** argv) in
c:\work\xml_rea der\xml_reader. cpp:line 74

This error comes from while (reader->Read()) command, so although I have
#define _UNICODE and changed my char to wchar_t, still getting the error.

Leads me to believe the XmlTextReader is not set up to read unicode.

How would I fix this?

Many, many thanks for your help!!! <Exasperated>

Nov 12 '05 #4

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

Similar topics

3
4425
by: Ekempd | last post by:
I'm trying to read the following XML file: <mail> <from>Rae</from> <subject>Informacion de su Proceso de Titulacion</subject> <body_mail> <!]> </body_mail> </mail>
3
4542
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 fine: XmlTextReader reader = new XmlTextReader( @"e:\bobo.xml" ); reader.Read(); But this fails reporting, "This is an unexpected token. The expected token is 'NAME'. Line 1, position 2.":
1
4173
by: Jordan | last post by:
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
13
3247
by: Rick | last post by:
The following code will enter an infinate loop when in ReadChars. I can only make it happen when reading a Stream and with this particular XML. If I use the ReadInnerXml call rather than my own ReadElementBodyAsXml the code works, but is less efficent. ReadElementBodyAsXml is required by my application with .Net Framework 1.1. The code breaks on the second call to ReadElementBodyAsXml with the inner xml: </EGDConfigExtension>...
0
8686
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9173
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9033
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8911
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6533
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2345
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.