简体   繁体   English

XQUERY SQL Server中节点XML文件中的解析器属性如何

[英]How parser properties in node XML file in XQUERY SQL server

I have this XML: 我有这个XML:

在此处输入图片说明

i want to get the value on Property name = "ParticipTypeName" i am using something like that: 我想获取Property name =“ ParticipTypeName”的值,我正在使用类似的方法:

;WITH XMLNAMESPACES(DEFAULT     'http://xml.common.asset.aoma.sonymusic.com/ProductMetadata.xsd')
SELECT   
    x.u.value('(/BusinessUnitProperties/Property[@name = "ParticipTypeName"])[1]', 'varchar(100)') as ParticipTypeName
from 
    @XML.nodes('/ProductMetadata/Tracks/Track/Participants/Participant') x(u)

it doesn't work. 它不起作用。 How I should get the value in this property? 我应该如何获得该物业的价值?

Try this: 尝试这个:

SELECT x.u.value('(//*:Property[@*:name="ParticipTypeName"])[1]','nvarchar(max)')

The // will search for any element <Property> . //将搜索任何元素<Property> The XQuery -filter will choose the one with the name you are looking for. XQuery -filter将选择您要查找的名称。 The *: will allow you to ignore the namespace. *:将允许您忽略名称空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM