Home Forums Programming XML Legal / Illegal XML Characters list RE: Legal / Illegal XML Characters list

  • Paul Bradshaw (3/18/2015)


    I'm having this same issue as the OP of this thread... I cannot find the "problem character" at all. It's at "line 554, character 18", but no matter how I do things, I can't find 550 lines in this XML. I pasted it into Notepad++ and formatted as XML with linebreaks, and Notepad++ thinks it's well formed with no errors, and there's only 520 lines.

    Shot in the dark here...does your source data contain an ASCII NULL (CHAR(0)) perhaps?

    You say that SQL Server is complaining about an error in your XML on a line that doesn't appear to exist, but maybe it actually does exist. ASCII NULL is often treated as an "end of file" or "end of string", so your text editor (and the SQL Server editor) may be seeing a NULL and assuming that the NULL is the "end of the file" and is truncating the value at that point.

    You might try looking at the source data in a binary editor instead of a text editor if you can. If your data contains an ASCII NULL then you should be able to see it that way. If it does have a NULL Then you'll have to escape it somehow, but I'm not sure exactly how you're going to accomplish that. If it were me and it was an option, I'd go back to whomever is giving me the data and ask them to encode the data in a format that's more XML friendly (e.g. base-64 maybe).