我在尝试添加具有非法字符的元素时遇到问题。我有以下 SQL
SELECT
'en-GB' AS '@xml:lang',
'20120217164611.1712._3FO0ZXYQ3@GBRAPPCHL1' AS '@payloadID',
'2012-02-17T16:46:11' AS '@timestamp',
'1.2.014' AS '@version',
( SELECT
( SELECT /* FROM */
(SELECT 'TecSolExchangeID' AS 'Credential/@domain', 33333 AS 'Credential/Identity'
FOR XML PATH(''), TYPE),
(SELECT 'name' AS 'Credential/@domain', 'Test Limited' AS 'Credential/Identity'
FOR XML PATH(''), TYPE)
FOR XML PATH('From'), TYPE ),
( SELECT /* TO */
(SELECT 'TecSolExchangeID' AS 'Credential/@domain', 66666 AS 'Credential/Identity'
FOR XML PATH(''), TYPE),
(SELECT 'name' AS 'Credential/@domain', 'Test Company' AS 'Credential/Identity'
FOR XML PATH(''), TYPE)
FOR XML PATH('To'), TYPE ),
( SELECT /* SENDER */
(SELECT 'TecSolExchangeID' AS 'Credential/@domain', 13041 AS 'Credential/Identity', '' AS 'Credential/SharedSecret'
FOR XML PATH(''), TYPE), ' cXML Link v1.3.0' AS 'UserAgent'
FOR XML PATH('Sender'), TYPE )
FROM TEST2.PORDER
WHERE POHNUM_0 = '2011302POH00000002'
FOR XML PATH('Header'),TYPE )
, ( SELECT 'production' AS '@deploymentMode',
( SELECT
( SELECT /* ShipNoticeHeader */
(SELECT ''
FOR XML PATH(''),
TYPE)
FOR XML PATH('ShipNoticeHeader'),
TYPE ),
( SELECT '' AS '@domain',
'' as 'CarrierIdentfier',
''AS 'ShipmentIdentifier'
FOR XML PATH('ShipControl'),
TYPE ),
(SELECT /* Ship Notice Portion */
(SELECT '1;29117/42' AS 'DocumentReference/@PayLoadID',
'' AS 'DocumentReference'
FOR XML PATH('OrderReference'),
TYPE),
(SELECT '4' AS '@Quantity',
'1' AS '@LineNo',
'Box 4' AS 'UnitOfMeasure'
FOR XML PATH('ShipNoticeItem'),
TYPE)
FOR XML PATH('ShipNoticePortion'),
TYPE)
FROM TEST2.PORDER
WHERE POHNUM_0 = '2011302POH00000002'
FOR XML PATH('ShipNoticeRequest'),
TYPE )
FROM TEST2.PORDER
WHERE POHNUM_0 = '2011302POH00000002'
FOR XML PATH('Request'),
TYPE)
FROM TEST2.PORDER
WHERE POHNUM_0 = '2011302POH00000002'
FOR XML PATH('?XML')
如您所见,我在根字段中有一个问号。这失败并出现错误。'?XML' 包含 FOR XML 要求的无效 XML 标识符;'?'(0x003F) 是第一个错误字符'。
我的问题是我需要能够创建包含非法字符的元素。例如,我还需要围绕消息的另一个元素,即“<!DOCTYPE>”。相同的场景,除了这个字段有一个感叹号。
这是否可能首先完成,如果可以,任何人都可以帮我完成它。
提前致谢