【发布时间】:2020-06-29 09:07:07
【问题描述】:
我有一个问题,我需要将一堆 XML 文件解析到一个 SQL 数据库中,其中所需的元素都位于 XML 文件的不同分支中。 到目前为止,我在 Google 上搜索和查看的每个示例都处理相当简单的 XML 树。
这是 XML 文件标头中引用的架构:http://service.ddex.net/xml/ern/37/release-notification.xsd
简化的 XML:
<store>
<bookstore>
<book>
<ref_title>
<title>Harry Potter</title>
</ref_title>
<ref_author>
<author>J K. Rowling</author>
</ref_author>
<year>
<this_year>2005</this_year>
</year>
<price>
<dollar>usd</dollar>
<value>29.99</value>
</price>
<price>
<dollar>aud</dollar>
<value>49.99</value>
</price>
</book>
<book>
<ref_title>
<title>Petes Book of Pie</title>
</ref_title>
<ref_author>
<author>Pete P</author>
</ref_author>
<year>
<this_year>1999</this_year>
</year>
<price>
<dollar>usd</dollar>
<value>19.99</value>
</price>
<price>
<dollar>aud</dollar>
<value>39.99</value>
</price>
</book>
</bookstore>
</store>
我需要结束这个:
TITLE AUTHOR YEAR DOLLAR VALUE
Harry Potter J K. Rowling 2005 usd 49.99
Petes Book of Pie Pete P 1999 usd 19.99
我正在使用 Microsoft SQL 2019,并希望能够在 SQL-T 中完成这一切,但我也查看了 Python 示例,但没有运气。
有什么建议吗?
【问题讨论】:
标签: sql sql-server xml