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

illegal character in xml file

Hi,

I have an XML file that was created as a DOM tree in .Net 1.1 and serialized
to disk. If I try to put character code 1 inside one of the attributes
(don't ask why), it seems to serialize perfectly ok and I get a file that
looks like this:

<element attribute="" />

which looks perfectly valid but won't open up with an XML viewer because it
says it is an illegal character reference.

what am I missing here? surely it's legal to put any character reference in
an XML file as long as it's correctly encoded? and if it's not, how come the
framework serialized it for me without complaining?

TIA

Andy
Feb 6 '07 #1
2 6204
* Andy Fish wrote in microsoft.public.dotnet.xml:
>what am I missing here? surely it's legal to put any character reference in
an XML file as long as it's correctly encoded? and if it's not, how come the
framework serialized it for me without complaining?
No, that's not legal, see http://www.w3.org/TR/xml for which characters
are allowed. In XML 1.0, U+0001 is not one of them. I think the API docs
warn you that some of the serialization functions do not check for well-
formedness.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Feb 6 '07 #2
Andy Fish wrote:
I have an XML file that was created as a DOM tree in .Net 1.1 and serialized
to disk. If I try to put character code 1 inside one of the attributes
(don't ask why), it seems to serialize perfectly ok and I get a file that
looks like this:

<element attribute="" />

which looks perfectly valid but won't open up with an XML viewer because it
says it is an illegal character reference.

what am I missing here? surely it's legal to put any character reference in
an XML file as long as it's correctly encoded? and if it's not, how come the
framework serialized it for me without complaining?
With XML 1.0  is not well-formed. The XML parser and serializer in
..NET 1.x allows it nevertheless but that is a known flaw. With .NET 2.0
(still supporting XML 1.0) the parsing and serialization is more strict
by default although there are settings you can choose not to check
character references.
See
<http://msdn2.microsoft.com/en-us/library/system.xml.xmlreadersettings.checkcharacters.aspx>

I don't think there is anything you can do with .NET 1.x to have the
parser or serializer throw an error on e.g. .
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Feb 6 '07 #3

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

Similar topics

28
by: dingbat | last post by:
I'm writing a "tabbed folder" nav bar. Site standards are graphical prettiness, CSS throughout, valid code, but accesibility is ignored where it conflicts with prettiness. The particular issue...
14
by: deko | last post by:
Is there a way to check user input for illegal characters? For example, a user enters something into a text box and clicks OK. At that point I'd like to run code such as this: illegal =...
3
by: Eckhard Schwabe | last post by:
I only found one post on Google where someone mentions the same problem with a DataSet: XmlDataReader in .Net 1.1 can not read XML files from a path which contains "%10" or "%3f". code to...
1
by: Shilpa | last post by:
Hi, I have a OpenFileDialog on my windows form whose filter is *.*. I want the users to be able to further filter the files by giving *.doc or *.zip etc in the "file name" field of the dialog...
16
by: DBC User | last post by:
Hi, I have a small XML file, I uploaded to a web page. I have the following code to convert the content I downloaded from web to xml and is giving "Illegal characters in path", but when I try to...
3
by: =?Utf-8?B?SG9seXNtb2tl?= | last post by:
Hi there, I am having a problem im my webservices method when trying to save a file with latin characters to disk passed through WSE. I have noticed that when trying to read the file name from...
1
by: Andy Fish | last post by:
Hi, I have an XML file that was created as a DOM tree in .Net 1.1 and serialized to disk. If I try to put character code 1 inside one of the attributes (don't ask why), it seems to serialize...
3
by: Tarik Monem | last post by:
Hi Everyone, Still a newbie with FLEX, and I've passed arrays using AJAX to FLEX before, but I've never passed links to FLEX. Basically, this is the OUTPUT, which I wanted, but I'm given an...
2
by: Kamaria | last post by:
I wrote this program to calculate the income tax of a user depending on whether or not they were married: import javax.swing.JOptionPane; public class Income_Tax { public static void main...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.