473,811 Members | 2,749 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6234
* Andy Fish wrote in microsoft.publi c.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****@h oehrmann.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.xmlr eadersettings.c heckcharacters. 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
2962
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 here is that the graphic designer wants a pretty (non-webbable) font on the shaded nav tabs, so I'm reduced to using bitmaps. To make the 4-way rollovers ("current" and "hover" states) work I'm using the standard "rollerblind" technique with a...
14
42436
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 = Array(\, /, :, *, ?, ", <, >, |) If Me.TextBox Contains illegal Then MsgBox "You entered illegal characters. Please try again." Me.TextBox = Null
3
15787
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 reproduce: string filename = "%10.xml"; //XML file with this name is existing XmlReader reader = new XmlTextReader(filename);
1
2336
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 (Just like it happens in the open file dialog of MS Word) Currently, if the user enters a wild card character in the file name field, it is throwing an exception with the message "Illegal characters in path". Please let me know how to achieve the...
16
7517
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 see the value in XML viewer (through add watch) and is showing the content correctly. Here is the code ... string b = wc.DownloadString(myurl);
3
3026
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 all the latin characters are converted ? character which is a illegal character for file name. If my file name is N° documento per Romà
1
801
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 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
3
3535
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 error of "illegal character," from the JavaScript console: Error: illegal character Source Code:
2
17825
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 (String args) {
0
9605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10647
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
10133
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9204
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7669
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
6889
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
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
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.