I am generating an XML document from a StringBuilder, basically something like:
string.Format("<text><row>{0}</row><col>{1}</col><textHeight>{2}</textHeight><textWidth>{3}</textWidth><data>{4}</data><rotation>{5}</rotation></text>
Later, something like:
XmlDocument document = new XmlDocument();
document.LoadXml(xml);
XmlNodeList labelSetNodes = document.GetElementsByTagName("labels");
for (int index = 0; index < labelSetNodes.Count; index++)
{
//do something
}
All the data comes from a database.
Recently I've had a few issues with the error:
Hexadecimal value 0x00 is a invalid character, line 1, position nnnnn
But its not consistent.
Sometimes some 'blank' data will work.
The 'faulty' data works on some PCs, but not others.
In the database, the data is always a blank string. It is never 'null'
and in the XML file, it comes out as < data>< /data>
, i.e. no character between opening and closing. (but not sure if this can be relied on as I am pulling it from the 'immediate' window is vis studio and pasting it into textpad).
There is possibly differences in the versions of sql server (2008 is where it would fail, 2005 would work) and collation too.
Not sure if any of these are likely causes?
But exactly the same code and data will sometimes fail. Any ideas where the problem lies?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…