如何获取 SQLXML 中每个属性的名称、值和父元素名称?
给定这个 SQL:
DECLARE @content XML
SET @content =
'<people>
<person id="1" bimble="1">
<firstname bobble="gomble">John</firstname>
<surname>Doe</surname>
</person>
<person id="2" bimble="11">
<firstname bobble="zoom">Mary</firstname>
<surname>Jane</surname>
</person>
<person id="4" bimble="10">
<firstname bobble="womble">Matt</firstname>
<surname>Spanner</surname>
</person>
</people>'
我想检索每个属性,它的值和父元素的名称作为表:
Parent Name Attribute Name Attribute Value
----------- -------------- ---------------
person id 1
person bimble 1
firstname bobble gomble
person id 2
person bimble 11
firstname bobble zoom
person id 4
person bimble 10
firstname bobble womble
Given this SQL:
DECLARE @content XML
SET @content =
'<people>
<person id="1" bimble="1">
<firstname bobble="gomble">John</firstname>
<surname>Doe</surname>
</person>
<person id="2" bimble="11">
<firstname bobble="zoom">Mary</firstname>
<surname>Jane</surname>
</person>
<person id="4" bimble="10">
<firstname bobble="womble">Matt</firstname>
<surname>Spanner</surname>
</person>
</people>'
I want to retrieve every attribute, it's value and parent element's name as a table:
Parent Name Attribute Name Attribute Value
----------- -------------- ---------------
person id 1
person bimble 1
firstname bobble gomble
person id 2
person bimble 11
firstname bobble zoom
person id 4
person bimble 10
firstname bobble womble
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最初的回答(针对我自己的问题):
My initial answer (to my own question):