【发布时间】:2018-10-15 11:02:01
【问题描述】:
How can i extract xml data in tabular format in Sql Server. the sample xml field is something like this
<?xml version='1.0' encoding='UTF-8'?>
<root>
<element1>
<Header Client_ID="100" Sent_date_time="2015-03-02T9:30:43.808-06:00"/>
<element2>
<element3 UnitPrice="3.2" ItemID="njh1"/>
<element3 UnitPrice="4.1" ItemID="ole5"/>
<element3 UnitPrice="4.6" ItemID="usd3"/>
<element3 UnitPrice="8.2" ItemID="eor9"/>
<element3 UnitPrice="2.9" ItemID="abc8"/>
<element3 UnitPrice="5.1" ItemID="gfd3"/>
<element3 UnitPrice="4.9" ItemID="kdu0"/>
<element3 UnitPrice="6.1" ItemID="uso8"/>
</element2>
</element1>
</root>
我无法从上述 xml 数据字段中提取数据。我需要一个输出,其中数据保存在两列中,即 itemid 和 unitprice
【问题讨论】:
-
您可以使用 XSLT 样式表处理 XML 数据以生成您需要的 HTML。
-
您能推荐一个示例查询吗?
-
XSLT 与查询无关。请在您首选的互联网搜索引擎中输入该词并仔细阅读。
-
但是我需要从sql表的xml字段中提取数据并保存在另一个表中以供查询
标签: sql sql-server xml tsql