The quest for 0x0B

后端 未结 3 782
遇见更好的自我
遇见更好的自我 2020-12-21 07:27

I get this error when reading some data from an SQL column then converting it to XML:

\"System.InvalidOperationException: There is an error in XML document (182, 16

3条回答
  •  粉色の甜心
    2020-12-21 08:20

    Finally found it !

    The .NET XML serializer was escaping the invalid character when serializing it, but then it was un-escaping it before de-serialization.

    So I had to search for the escaped to find the un-escaped 0x0B ... seriously not funny guys!

    So this:

      SELECT * from Mytable where Column like '%' + '' + '%'
    

    Will actually find this:

    
          313_other_10
    

    And while this looks like valid XML it will throw an invalid character exception when :

        XmlSerializer xs = new XmlSerializer(Type.GetType(Hashtable));
        StringReader stringReader = new StringReader(xml);
        obj = xs.Deserialize(stringReader);
    

    Many thanks to people who jumped in to help! It was unvaluable help!

提交回复
热议问题