Search 0x0B

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

"System.InvalidOperationException: there is an error in the XML document (182, 16). ---> System.Xml.XmlException: '', the hexadecimal value 0x0B is an invalid character."

Fair enough, maybe the data is distorted. Also, how can I find a criminal string?

SELECT * from Mytable where Column like '%' + char(0x0B)+'%' 

returns empty.

(obviously, I tried to use all% + char, char, char +% combinations, just in case)

+3
source share
3 answers

Finally found it!

.NET XML , -.

, escaped & #xB, un-escaped 0x0B... !

, :

  SELECT * from Mytable where Column like '%' + '&#xB' + '%'

:

<?xml version="1.0"?>
      <Hashtable><key>313_other_10</key><value>&#xB</value></Hashtable>

XML, , :

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

, , ! !

+5

nchar(0x0B) char(0x0B)? , - Unicode.

+3

A character 0x0Bcannot be used in an XML document (see the list of valid XML characters here .) Please consider migrating invalid XML characters like this into valid XML (for example, a sequence &#xB;).

0
source

Source: https://habr.com/ru/post/1723033/


All Articles