以下是XML返回的部分内容:
XML(可扩展标记语言)的返回,部分如下:
<Order xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:d1p2="http://schemas.abccompany.com/oml/package/1.0" xmlns:d1p1="http://schemas.abccompany.com/oml/batch/1.0" xmlns="http://schemas.abccompany.com/oml/base/1.0" intendedUse="0" quoteBack="5062-JA$181-3282" d1p1:transactionId="00000000-0000-0000-0000-000000000000" d1p2:uri="asdfasd-afdadfs-adsasdf" d1p1:customerId="0" d1p1:userId="0" d1p1:enabled="false" d1p1:priority="Low" d1p1:frequency="0" d1p1:recordCount="0" d1p1:executionPeriod="Once">
<Security xmlns="http://schemas.abccompany.com/oml/security/1.0">
<RootCredentials username="ust_3dResults2" password="1234567" />
<LocationID>abcd</LocationID>
<AccountID>9876</AccountID>
<CustomerUserReferenceID>ssmart</CustomerUserReferenceID>
</Security>
</Order>
使用T-SQL,我该如何提取“AccountID”?我尝试过:
;WITH xmlnamespaces('http://www.w3.org/2001/XMLSchema' AS xsd, DEFAULT 'http://www.w3.org/2001/XMLSchema')
SELECT adr.id,
adr.omlinput,
adr.omlinput.value('(/Order/Security/AccountID)[1]', 'varchar(50)') AS [Results]
FROM [Reporting].[ApplicantDirectRequest] adr WITH (NOLOCK)
WHERE adr.OmlInput IS NOT NULL
并且
;WITH xmlnamespaces('http://www.w3.org/2001/XMLSchema' AS xsd, DEFAULT 'http://www.w3.org/2001/XMLSchema')
SELECT adr.id,
adr.omlinput,
adr.omlinput.value('(/xsd:Order/Security/AccountID)[1]', 'varchar(50)') AS [Results]
FROM [Reporting].[ApplicantDirectRequest] adr WITH (NOLOCK)
WHERE adr.OmlInput IS NOT NULL
xsi
和xsd
前缀的命名空间)可以省略 - 其他需要被定义。 - marc_sxmlns="..."
没有任何前缀),并且它本身也没有前缀,那么它就是属于其父节点所适用的XML命名空间(该命名空间可能不是直接在父节点上定义的,而是在更高层次上定义的)。 - marc_s