We will get this error when we are trying to query XML in SQL Server.
Each and every XML node should have closing node like this <element>....</element>. XML will become invalid when it has backslash "\" instead of forward slash "/" and below error will be throwed :
Msg 9455, Level 16, State 1, Line 1
XML parsing: line 6, character 2, illegal qualified name character
DECLARE @X XML = '
<row>
<name>spt_fallback_db</name>
<schema_id>1</schema_id>
<type_desc>USER_TABLE</type_desc>
<\row>'SELECT @X
In the above XML, backslash "\" is used instead of forward slash "/" at the end <\row>

Check all the enclosing XML tags have forward slash "/" to fix or avoid this error.
Note : This error can also be encountered under various other scenarios. I will keep updating this article.
Each and every XML node should have closing node like this <element>....</element>. XML will become invalid when it has backslash "\" instead of forward slash "/" and below error will be throwed :
Msg 9455, Level 16, State 1, Line 1
XML parsing: line 6, character 2, illegal qualified name character
To resolve the error :
DECLARE @X XML = '
<row>
<name>spt_fallback_db</name>
<schema_id>1</schema_id>
<type_desc>USER_TABLE</type_desc>
<\row>'SELECT @X
In the above XML, backslash "\" is used instead of forward slash "/" at the end <\row>
Check all the enclosing XML tags have forward slash "/" to fix or avoid this error.
Note : This error can also be encountered under various other scenarios. I will keep updating this article.
SELECT * FROM Sys.messages WHERE language_id = 1033 AND message_id = 9455
No comments:
Post a Comment