exclamation mark in sql xml -
i have problem trying add element illegal character. have following sql
select 'en-gb' '@xml:lang', '20120217164611.1712._3fo0zxyq3@gbrappchl1' '@payloadid', '2012-02-17t16:46:11' '@timestamp', '1.2.014' '@version', ( select ( select /* */ (select 'tecsolexchangeid' 'credential/@domain', 33333 'credential/identity' xml path(''), type), (select 'name' 'credential/@domain', 'test limited' 'credential/identity' xml path(''), type) xml path('from'), type ), ( select /* */ (select 'tecsolexchangeid' 'credential/@domain', 66666 'credential/identity' xml path(''), type), (select 'name' 'credential/@domain', 'test company' 'credential/identity' xml path(''), type) xml path('to'), type ), ( select /* sender */ (select 'tecsolexchangeid' 'credential/@domain', 13041 'credential/identity', '' 'credential/sharedsecret' xml path(''), type), ' cxml link v1.3.0' 'useragent' xml path('sender'), type ) test2.porder pohnum_0 = '2011302poh00000002' xml path('header'),type ) , ( select 'production' '@deploymentmode', ( select ( select /* shipnoticeheader */ (select '' xml path(''), type) xml path('shipnoticeheader'), type ), ( select '' '@domain', '' 'carrieridentfier', ''as 'shipmentidentifier' xml path('shipcontrol'), type ), (select /* ship notice portion */ (select '1;29117/42' 'documentreference/@payloadid', '' 'documentreference' xml path('orderreference'), type), (select '4' '@quantity', '1' '@lineno', 'box 4' 'unitofmeasure' xml path('shipnoticeitem'), type) xml path('shipnoticeportion'), type) test2.porder pohnum_0 = '2011302poh00000002' xml path('shipnoticerequest'), type ) test2.porder pohnum_0 = '2011302poh00000002' xml path('request'), type) test2.porder pohnum_0 = '2011302poh00000002' xml path('?xml')
as can see have question mark in root field. fails error. '?xml' contains invalid xml identifier required xml; '?'(0x003f) first character @ fault'.
my question need able create element illegal characters in. example need element surrounding message "<!doctype>". same scenario except field has exclamation mark.
is possible first off, , if so, can me finish off.
thanks in advance
you cannot part of for xml
can achieve using combination of for xml
, nvarchar
manipulation.
so if want add doctype (because in reality generating html), can this:
select '<!doctype html>' + cast( ( -- xml bit here -- replace xml query. select ( select 'a1' union select 'a2' ) xml path(''), root('z'), type ) nvarchar(max))
however note result not xml suitable sql server re-import.
discussion
xml , html related (both being types of sgml), not same. html has features xml not, , xml has features html not.
you can write subset of xml subset of html, useful, neither 1 subset of other.
Comments
Post a Comment