illegal character in xml file

Discussion in 'XML' started by Andy Fish, Feb 6, 2007.

  1. Andy Fish

    Andy Fish Guest

    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
    Andy Fish, Feb 6, 2007
    #1
    1. Advertising

  2. Andy Fish wrote:
    > 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...").



    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
    Joseph Kesselman, Feb 6, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. William Brogden
    Replies:
    1
    Views:
    8,355
    Manoj S. P.
    Jun 30, 2003
  2. Michael Lee
    Replies:
    0
    Views:
    1,549
    Michael Lee
    Jun 27, 2003
  3. Timo Nentwig
    Replies:
    1
    Views:
    3,550
    Igor N. Kolomiyets
    Feb 6, 2004
  4. Steve Rainbird

    illegal escape character

    Steve Rainbird, Jun 7, 2006, in forum: Java
    Replies:
    7
    Views:
    18,289
    Mark Space
    Jun 8, 2006
  5. Mike McGranahan

    XML serialization of illegal character entities

    Mike McGranahan, Jul 11, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    255
    Mike McGranahan
    Jul 11, 2006
Loading...

Share This Page