问题描述
我有可以从 XML 文件中选择几个值的工作代码.问题是我有多个同名的节点.
I have working code that can select a few values from an XML file. The problem is that I have multiple nodes with the same name.
这是 XML 的一个片段:
Here is a snippet of the XML:
我的 SQL 如下:
我无法得到我需要的是 [组件 2].我想基本上选择文件中的所有Address_Component_Type_ID",但它们的名称都相同,并且在名称相同的其他节点下.如何在我的 SQL 中指定获取所有组件类型?感谢您的关注!
Where I can't get what I need is the [Component 2]. I want to basically select ALL of the "Address_Component_Type_ID" in the file, but they are all named the same and under other nodes that are named the same. How can I specify in my SQL to grab all of the Component Types? Thank you for looking!
推荐答案
取决于您想要做什么...如果您知道正好有 2 个Address_Components"要抓取,您可以像这样修改您的查询:
Depends what you want to do... If you know there are exactly 2 "Address_Components" that you want to grab, you can modify your query like so:
结果如下:
但是,如果可以有任意数量的Address_Components",并且您想将它们抓取到单独的记录中,您可以像这样重写您的查询:
However, if there can be any number of "Address_Components", and you want to grab them into separate records, you can rewrite your query like this:
结果如下:
这篇关于XML to SQL - 选择多个同名节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!