Sql server 2008 在SQLServer2008中解析带有命名空间的XML
我的表中有以下xml。我想获取fv节点的ID: 还是不Sql server 2008 在SQLServer2008中解析带有命名空间的XML,sql-server-2008,xml-parsing,xml-namespaces,Sql Server 2008,Xml Parsing,Xml Namespaces,我的表中有以下xml。我想获取fv节点的ID: 还是不 假设您的表名为YourTable,XML列名为XmlData,请根据您的实际情况进行调整和更改!,您可以尝试以下XQuery代码: -- declare the XML namespace as the DEFAULT ;WITH XMLNAMESPACES(DEFAULT 'bb_appfx_dataforms') SELECT -- extract the value from the <Value>
假设您的表名为YourTable,XML列名为XmlData,请根据您的实际情况进行调整和更改!,您可以尝试以下XQuery代码:
-- declare the XML namespace as the DEFAULT
;WITH XMLNAMESPACES(DEFAULT 'bb_appfx_dataforms')
SELECT
-- extract the value from the <Value> subnode of the <fv> node, if found
FvValue = XC.value('(Value)[1]', 'varchar(200)')
FROM
dbo.YourTable
CROSS APPLY
-- get a list of XML fragments - one for each <fv> node
XmlData.nodes('/DataFormItem/Values/fv') AS XT(XC)
WHERE
-- find the XML fragment with the ID="Description"
XC.value('@ID', 'varchar(50)') = 'Description'
欢迎来到Stackoverflow。如果你能分享一个
-- declare the XML namespace as the DEFAULT
;WITH XMLNAMESPACES(DEFAULT 'bb_appfx_dataforms')
SELECT
-- extract the value from the <Value> subnode of the <fv> node, if found
FvValue = XC.value('(Value)[1]', 'varchar(200)')
FROM
dbo.YourTable
CROSS APPLY
-- get a list of XML fragments - one for each <fv> node
XmlData.nodes('/DataFormItem/Values/fv') AS XT(XC)
WHERE
-- find the XML fragment with the ID="Description"
XC.value('@ID', 'varchar(50)') = 'Description'