怎么取XML节点的值? 没法标颜色,上面xml第一行, 这2个标签请去掉,标签里面的内容在我SQL查询分析器里老有问题,是怎么回事? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 declare @xml xmlset @xml='<ProductCatalog><Products> <Product inventoryId="5739" name="Born Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 pack" displayProfile="standard"> <Variations> <Variation inventoryId="BF-001" name="Born Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 pack"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-001.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5740" name="Born Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 pack" displayProfile="standard"> <Variations> <Variation inventoryId="BF-002" name="Born Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 pack"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-002.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5741" name="Born Free Vented Glass Bottle - 1 pack" displayProfile="standard"> <Variations> <Variation inventoryId="BF-003" name="Born Free Vented Glass Bottle - 1 pack"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-003.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5742" name="Born Free Bisphenol-A Free Plastic Training Cup - 7 oz" displayProfile="standard"> <Variations> <Variation inventoryId="BF-004" name="Born Free Bisphenol-A Free Plastic Training Cup - 7 oz"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-004.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5743" name="Born Free Bisphenol-A Free Plastic Drinking Cup - 9 oz" displayProfile="standard"> <Variations> <Variation inventoryId="BF-005" name="Born Free Bisphenol-A Free Plastic Drinking Cup - 9 oz"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-005.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> </Products> </ProductCatalog>'select t.x.value('@inventoryId','int') as inventoryIdfrom @xml.nodes('//Product') as t(x)57395740574157425743 谢谢LS的高人, 但为什么xml第一行写成<ProductCatalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:drive="http://fluid.com/drive" xmlns="http://fluid.com/drive/catalog" xsi:schemaLocation="http://fluid.com/drive/catalog http://www.fluidretail.net/schemas/DriveProductCatalog.xsd">结果会是空的呢?源数据就有后面那一串东西,没法去掉。 declare @xml xml select @xml = '<ProductCatalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:drive="http://fluid.com/drive" xmlns="http://fluid.com/drive/catalog" xsi:schemaLocation="http://fluid.com/drive/catalog http://www.fluidretail.net/schemas/DriveProductCatalog.xsd"> <Products> <Product inventoryId="5739" name="Born Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 pack" displayProfile="standard"> <Variations> <Variation inventoryId="BF-001" name="Born Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 pack"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-001.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5740" name="Born Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 pack" displayProfile="standard"> <Variations> <Variation inventoryId="BF-002" name="Born Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 pack"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-002.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5741" name="Born Free Vented Glass Bottle - 1 pack" displayProfile="standard"> <Variations> <Variation inventoryId="BF-003" name="Born Free Vented Glass Bottle - 1 pack"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-003.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5742" name="Born Free Bisphenol-A Free Plastic Training Cup - 7 oz" displayProfile="standard"> <Variations> <Variation inventoryId="BF-004" name="Born Free Bisphenol-A Free Plastic Training Cup - 7 oz"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-004.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5743" name="Born Free Bisphenol-A Free Plastic Drinking Cup - 9 oz" displayProfile="standard"> <Variations> <Variation inventoryId="BF-005" name="Born Free Bisphenol-A Free Plastic Drinking Cup - 9 oz"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-005.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> </Products></ProductCatalog>'--查询结果select li.x.value('@name','varchar(200)') as name from @xml.nodes('//Product') as li(x)--结果是空的name 如果把那两个标记去掉--结果为 nameBorn Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 packBorn Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 packBorn Free Vented Glass Bottle - 1 packBorn Free Bisphenol-A Free Plastic Training Cup - 7 ozBorn Free Bisphenol-A Free Plastic Drinking Cup - 9 oz分析原因 SQL Server 2005 XML 数据类型实现了 ISO SQL-2003 标准 XML 数据类型。因此,它不仅可以存储格式良好的 XML 1.0 文档,而且可以存储所谓的 XML 内容片段(带有文本节点和任意数目的顶层元素)。在对数据进行格式良好性检查时,并不要求将 XML 数据类型绑定到 XML 架构,但是格式不规范的数据将被拒绝。 楼主的标识内容并非完全符合ISO SQL-2003标准。 是xmlns=惹的祸。xml name space?我把xmlns=替换成a=, 先将就着用. declare @xml xml select @xml = '<ProductCatalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:drive="http://fluid.com/drive" xmlns="http://fluid.com/drive/catalog" xsi:schemaLocation="http://fluid.com/drive/catalog http://www.fluidretail.net/schemas/DriveProductCatalog.xsd"> <Products> <Product inventoryId="5739" name="Born Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 pack" displayProfile="standard"> <Variations> <Variation inventoryId="BF-001" name="Born Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 pack"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-001.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5740" name="Born Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 pack" displayProfile="standard"> <Variations> <Variation inventoryId="BF-002" name="Born Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 pack"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-002.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5741" name="Born Free Vented Glass Bottle - 1 pack" displayProfile="standard"> <Variations> <Variation inventoryId="BF-003" name="Born Free Vented Glass Bottle - 1 pack"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-003.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5742" name="Born Free Bisphenol-A Free Plastic Training Cup - 7 oz" displayProfile="standard"> <Variations> <Variation inventoryId="BF-004" name="Born Free Bisphenol-A Free Plastic Training Cup - 7 oz"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-004.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5743" name="Born Free Bisphenol-A Free Plastic Drinking Cup - 9 oz" displayProfile="standard"> <Variations> <Variation inventoryId="BF-005" name="Born Free Bisphenol-A Free Plastic Drinking Cup - 9 oz"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-005.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> </Products></ProductCatalog>'--查询结果;WITH XMLNAMESPACES( 'http://www.w3.org/2001/XMLSchema-instance' AS xsi, 'http://fluid.com/drive' AS drive, 'http://fluid.com/drive/catalog http://www.fluidretail.net/schemas/DriveProductCatalog.xsd' AS schemaLocation, DEFAULT 'http://fluid.com/drive/catalog')SELECT li.x.value('@name','varchar(200)') AS name FROM @xml.nodes('//Product') as li(x) --用xmlns,就得加dufault,其他的直接查就行了;WITH XMLNAMESPACES(DEFAULT 'http://fluid.com/drive/catalog')select t.x.value('@inventoryId','int') as inventoryIdfrom @xml.nodes('//Product') as t(x) declare @xml xmlset @xml='<ProductCatalog> <Products> <Product inventoryId="5739" name="Born Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 pack" displayProfile="standard"> <Variations> <Variation inventoryId="BF-001" name="Born Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 pack"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-001.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5740" name="Born Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 pack" displayProfile="standard"> <Variations> <Variation inventoryId="BF-002" name="Born Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 pack"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-002.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5741" name="Born Free Vented Glass Bottle - 1 pack" displayProfile="standard"> <Variations> <Variation inventoryId="BF-003" name="Born Free Vented Glass Bottle - 1 pack"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-003.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5742" name="Born Free Bisphenol-A Free Plastic Training Cup - 7 oz" displayProfile="standard"> <Variations> <Variation inventoryId="BF-004" name="Born Free Bisphenol-A Free Plastic Training Cup - 7 oz"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-004.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5743" name="Born Free Bisphenol-A Free Plastic Drinking Cup - 9 oz" displayProfile="standard"> <Variations> <Variation inventoryId="BF-005" name="Born Free Bisphenol-A Free Plastic Drinking Cup - 9 oz"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-005.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> </Products></ProductCatalog>'select d.c.value('@inventoryId' ,'int') from @xml.nodes('ProductCatalog/Products/Product') as d(c)-----------57395740574157425743 sqlserver怎么才能安装上啊!! sqlserver2005+sp3安装在2008,本地和网络程序都不能正常连接是咋回事?无防火墙 新手提问(怎么样对多条记录进行更新) 关于重装SQL2000后如何恢复!(请高手指点) 求助sql语句,显示重复大于N的记录 触发器问题,请大侠们指点 打开SQL服务器时出现错误,请高手指点 哪里有sql server可以下载,什么版本都行 如何做数据库备份方案才能确保数据安全 cross apply问题 如何筛选第n条后的记录 dtswiz命令谁用过啊? /i 和 /x 不能同时使用?
set @xml='
<ProductCatalog>
<Products>
<Product inventoryId="5739" name="Born Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 pack" displayProfile="standard"> <Variations> <Variation inventoryId="BF-001" name="Born Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 pack"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-001.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5740" name="Born Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 pack" displayProfile="standard"> <Variations> <Variation inventoryId="BF-002" name="Born Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 pack"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-002.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5741" name="Born Free Vented Glass Bottle - 1 pack" displayProfile="standard"> <Variations> <Variation inventoryId="BF-003" name="Born Free Vented Glass Bottle - 1 pack"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-003.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5742" name="Born Free Bisphenol-A Free Plastic Training Cup - 7 oz" displayProfile="standard"> <Variations> <Variation inventoryId="BF-004" name="Born Free Bisphenol-A Free Plastic Training Cup - 7 oz"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-004.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> <Product inventoryId="5743" name="Born Free Bisphenol-A Free Plastic Drinking Cup - 9 oz" displayProfile="standard"> <Variations> <Variation inventoryId="BF-005" name="Born Free Bisphenol-A Free Plastic Drinking Cup - 9 oz"> <SourceImages> <StaticSourceImage type="Both" viewName="Front">BF-005.jpg</StaticSourceImage> </SourceImages> </Variation> </Variations> </Product> </Products>
</ProductCatalog>
'
select t.x.value('@inventoryId','int') as inventoryId
from @xml.nodes('//Product') as t(x)5739
5740
5741
5742
5743
<ProductCatalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:drive="http://fluid.com/drive" xmlns="http://fluid.com/drive/catalog" xsi:schemaLocation="http://fluid.com/drive/catalog http://www.fluidretail.net/schemas/DriveProductCatalog.xsd">结果会是空的呢?源数据就有后面那一串东西,没法去掉。
select @xml = '
<ProductCatalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:drive="http://fluid.com/drive" xmlns="http://fluid.com/drive/catalog" xsi:schemaLocation="http://fluid.com/drive/catalog http://www.fluidretail.net/schemas/DriveProductCatalog.xsd">
<Products>
<Product inventoryId="5739" name="Born Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 pack" displayProfile="standard">
<Variations>
<Variation inventoryId="BF-001" name="Born Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 pack">
<SourceImages>
<StaticSourceImage type="Both" viewName="Front">BF-001.jpg</StaticSourceImage>
</SourceImages>
</Variation>
</Variations>
</Product>
<Product inventoryId="5740" name="Born Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 pack" displayProfile="standard">
<Variations>
<Variation inventoryId="BF-002" name="Born Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 pack">
<SourceImages>
<StaticSourceImage type="Both" viewName="Front">BF-002.jpg</StaticSourceImage>
</SourceImages>
</Variation>
</Variations>
</Product>
<Product inventoryId="5741" name="Born Free Vented Glass Bottle - 1 pack" displayProfile="standard">
<Variations>
<Variation inventoryId="BF-003" name="Born Free Vented Glass Bottle - 1 pack">
<SourceImages>
<StaticSourceImage type="Both" viewName="Front">BF-003.jpg</StaticSourceImage>
</SourceImages>
</Variation>
</Variations>
</Product>
<Product inventoryId="5742" name="Born Free Bisphenol-A Free Plastic Training Cup - 7 oz" displayProfile="standard">
<Variations>
<Variation inventoryId="BF-004" name="Born Free Bisphenol-A Free Plastic Training Cup - 7 oz">
<SourceImages>
<StaticSourceImage type="Both" viewName="Front">BF-004.jpg</StaticSourceImage>
</SourceImages>
</Variation>
</Variations>
</Product>
<Product inventoryId="5743" name="Born Free Bisphenol-A Free Plastic Drinking Cup - 9 oz" displayProfile="standard">
<Variations>
<Variation inventoryId="BF-005" name="Born Free Bisphenol-A Free Plastic Drinking Cup - 9 oz">
<SourceImages>
<StaticSourceImage type="Both" viewName="Front">BF-005.jpg</StaticSourceImage>
</SourceImages>
</Variation>
</Variations>
</Product>
</Products>
</ProductCatalog>'
--查询结果
select li.x.value('@name','varchar(200)') as name
from @xml.nodes('//Product') as li(x)
--结果是空的
name 如果把那两个标记去掉
--结果为
name
Born Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 pack
Born Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 pack
Born Free Vented Glass Bottle - 1 pack
Born Free Bisphenol-A Free Plastic Training Cup - 7 oz
Born Free Bisphenol-A Free Plastic Drinking Cup - 9 oz
分析原因
SQL Server 2005 XML 数据类型实现了 ISO SQL-2003 标准 XML 数据类型。因此,它不仅可以存储格式良好的 XML 1.0 文档,而且可以存储所谓的 XML 内容片段(带有文本节点和任意数目的顶层元素)。在对数据进行格式良好性检查时,并不要求将 XML 数据类型绑定到 XML 架构,但是格式不规范的数据将被拒绝。 楼主的标识内容并非完全符合ISO SQL-2003标准。
我把xmlns=替换成a=, 先将就着用.
select @xml = '
<ProductCatalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:drive="http://fluid.com/drive" xmlns="http://fluid.com/drive/catalog" xsi:schemaLocation="http://fluid.com/drive/catalog http://www.fluidretail.net/schemas/DriveProductCatalog.xsd">
<Products>
<Product inventoryId="5739" name="Born Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 pack" displayProfile="standard">
<Variations>
<Variation inventoryId="BF-001" name="Born Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 pack">
<SourceImages>
<StaticSourceImage type="Both" viewName="Front">BF-001.jpg</StaticSourceImage>
</SourceImages>
</Variation>
</Variations>
</Product>
<Product inventoryId="5740" name="Born Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 pack" displayProfile="standard">
<Variations>
<Variation inventoryId="BF-002" name="Born Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 pack">
<SourceImages>
<StaticSourceImage type="Both" viewName="Front">BF-002.jpg</StaticSourceImage>
</SourceImages>
</Variation>
</Variations>
</Product>
<Product inventoryId="5741" name="Born Free Vented Glass Bottle - 1 pack" displayProfile="standard">
<Variations>
<Variation inventoryId="BF-003" name="Born Free Vented Glass Bottle - 1 pack">
<SourceImages>
<StaticSourceImage type="Both" viewName="Front">BF-003.jpg</StaticSourceImage>
</SourceImages>
</Variation>
</Variations>
</Product>
<Product inventoryId="5742" name="Born Free Bisphenol-A Free Plastic Training Cup - 7 oz" displayProfile="standard">
<Variations>
<Variation inventoryId="BF-004" name="Born Free Bisphenol-A Free Plastic Training Cup - 7 oz">
<SourceImages>
<StaticSourceImage type="Both" viewName="Front">BF-004.jpg</StaticSourceImage>
</SourceImages>
</Variation>
</Variations>
</Product>
<Product inventoryId="5743" name="Born Free Bisphenol-A Free Plastic Drinking Cup - 9 oz" displayProfile="standard">
<Variations>
<Variation inventoryId="BF-005" name="Born Free Bisphenol-A Free Plastic Drinking Cup - 9 oz">
<SourceImages>
<StaticSourceImage type="Both" viewName="Front">BF-005.jpg</StaticSourceImage>
</SourceImages>
</Variation>
</Variations>
</Product>
</Products>
</ProductCatalog>'
--查询结果
;
WITH XMLNAMESPACES
(
'http://www.w3.org/2001/XMLSchema-instance' AS xsi,
'http://fluid.com/drive' AS drive,
'http://fluid.com/drive/catalog http://www.fluidretail.net/schemas/DriveProductCatalog.xsd' AS schemaLocation,
DEFAULT 'http://fluid.com/drive/catalog'
)
SELECT
li.x.value('@name','varchar(200)') AS name
FROM
@xml.nodes('//Product') as li(x)
--用xmlns,就得加dufault,其他的直接查就行了
;WITH XMLNAMESPACES(DEFAULT 'http://fluid.com/drive/catalog')
select t.x.value('@inventoryId','int') as inventoryId
from @xml.nodes('//Product') as t(x)
set @xml='<ProductCatalog>
<Products>
<Product inventoryId="5739" name="Born Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 pack" displayProfile="standard">
<Variations>
<Variation inventoryId="BF-001" name="Born Free Bisphenol-A Free Plastic Bottle - 9 oz - 2 pack">
<SourceImages>
<StaticSourceImage type="Both" viewName="Front">BF-001.jpg</StaticSourceImage>
</SourceImages>
</Variation>
</Variations>
</Product>
<Product inventoryId="5740" name="Born Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 pack" displayProfile="standard">
<Variations>
<Variation inventoryId="BF-002" name="Born Free Bisphenol-A Free Plastic Bottle - 5 oz - 2 pack">
<SourceImages>
<StaticSourceImage type="Both" viewName="Front">BF-002.jpg</StaticSourceImage>
</SourceImages>
</Variation>
</Variations>
</Product>
<Product inventoryId="5741" name="Born Free Vented Glass Bottle - 1 pack" displayProfile="standard">
<Variations>
<Variation inventoryId="BF-003" name="Born Free Vented Glass Bottle - 1 pack">
<SourceImages>
<StaticSourceImage type="Both" viewName="Front">BF-003.jpg</StaticSourceImage>
</SourceImages>
</Variation>
</Variations>
</Product>
<Product inventoryId="5742" name="Born Free Bisphenol-A Free Plastic Training Cup - 7 oz" displayProfile="standard">
<Variations>
<Variation inventoryId="BF-004" name="Born Free Bisphenol-A Free Plastic Training Cup - 7 oz">
<SourceImages>
<StaticSourceImage type="Both" viewName="Front">BF-004.jpg</StaticSourceImage>
</SourceImages>
</Variation>
</Variations>
</Product>
<Product inventoryId="5743" name="Born Free Bisphenol-A Free Plastic Drinking Cup - 9 oz" displayProfile="standard">
<Variations>
<Variation inventoryId="BF-005" name="Born Free Bisphenol-A Free Plastic Drinking Cup - 9 oz">
<SourceImages>
<StaticSourceImage type="Both" viewName="Front">BF-005.jpg</StaticSourceImage>
</SourceImages>
</Variation>
</Variations>
</Product>
</Products>
</ProductCatalog>'
select d.c.value('@inventoryId' ,'int') from @xml.nodes('ProductCatalog/Products/Product') as d(c)
-----------
5739
5740
5741
5742
5743