I am getting following error when i add <
in my xml,
Msg 9455, Level 16, State 1, Line 6 XML parsing: line 4, character 14, illegal qual
<
needs to be specified as <
in the XML
W < hite
Blue
Black
Green
Red
Apple
Pineapple
Grapes
Melon
Update:
The characters you need to escape in node values are <
=> <
and &
=> &
.
In attribute values you also need to escape "
=> "
if you use "
around your attribute values.
This is a valid XML:
- < > & ' "
Try it in a query:
declare @xml xml =
'
- < > & '' "
'
select @xml.value('(root/item)[1]', 'varchar(20)') as NodeValue,
@xml.value('(root/item/@att)[1]', 'varchar(20)') as AttValue
Result:
NodeValue AttValue
-------------------- --------------------
< > & ' " < > & ' "