Jul 30 2022 11:50 AM
When I cast a string (which is xml) to the xml data type and the node comments contain & it gets converted to &. For example:
Declare @xml xml =
'
<SHOP_INSTRUCTIONS>
Remove & return to stock.
</SHOP_INSTRUCTIONS>
';
Select @xml;
/*
Return This:
<SHOP_INSTRUCTIONS>
Remove & return to stock.
</SHOP_INSTRUCTIONS>
*/
I would expect the conversion to be: Remove & return to stock.
Am I getting the correct results, or what am I missing?
Thanks.
Aug 01 2022 01:04 AM
@Doug_Marquardt , & is just a different (decimal) encoding of & = ampersand.
See List of XML and HTML character entity references - Wikipedia
Aug 01 2022 05:30 AM
Yes, I realize that... but if I do this it throws an error:
Declare @xml xml =
'
<SHOP_INSTRUCTIONS>
Remove & return to stock.
</SHOP_INSTRUCTIONS>
';
Select @xml;
XML parsing: line 3, character 9, illegal name character
So how do I represent & as part of the node text?
Aug 01 2022 09:48 PM
SolutionAug 03 2022 06:22 AM
Aug 01 2022 09:48 PM
Solution