illegal character in xml file

A

Andy Fish

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
 
J

Joseph Kesselman

Andy said:
surely it's legal to put any character reference in
an XML file as long as it's correctly encoded?

No, it isn't. XML 1.0 limits the acceptable characters, and character
references do not work around those limits. (XML 1.1 relaxes this; see
the specs.)
> and if it's not, how come the
framework serialized it for me without complaining?

Becuase the framework thought it was writing XML 1.1? Or, more likely,
because the framework simply didn't bother checking. Enforcing these
rules does have performance costs, which leads some systems to default
to not doing so (or not offer the option at all, expecting that you'll
do it earlier in the pipeline -- "If it hurts when you do that...").
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top