我有3000个带有图书元数据的ONIX样式的xml。我想从这些文件中筛选出几个节点,并在单个工作表中将它们解析为Excel行。
这是一个XML路径的示例:http://btsoep.appspot.com/rest/book/9789082516425
我想过滤这些XML数据,如下所示
<Product>
<Title>
<TitleText>和
<Product>
<Contributor>
<PersonName>我需要在Excel工作表中检索到的数据,其中每个URL都有自己的行。因此PersonName在A行,TitleText在B行,URL在C行。
我该怎么做呢?
编辑1:
到目前为止,我尝试的是: xml首先下载所有的-using数据,然后尝试批量解析,这是excel。这是可行的,但不是必要的。-using中的默认XMLimport函数。我似乎不能批量运行它。
我没有任何过滤XML文件并在Excel工作表中解析它的经验。我不是要求任何人为我修复这个问题或为我编写代码,但我希望在好的方向上迈出一步。对于这种情况,哪种工具是最好的?再次感谢。
发布于 2017-09-07 01:14:19
这应该可以让你开始
Option Explicit
Sub parseONIX()
Dim URL As String
URL = "http://btsoep.appspot.com/rest/book/9789082516425"
' URL = "https://www.w3schools.com/xml/plant_catalog.xml"
Dim XMLPage As New MSXML2.XMLHTTP60
XMLPage.Open "GET", URL, False
XMLPage.send
Dim XMLDoc As New MSXML2.DOMDocument
XMLDoc.LoadXML XMLPage.responseText
Debug.Print XMLDoc.ChildNodes(0).BaseName
Debug.Print XMLDoc.ChildNodes(1).BaseName
Debug.Print XMLDoc.ChildNodes(1).ChildNodes(0).BaseName
Debug.Print XMLDoc.ChildNodes(1).ChildNodes(1).BaseName
Debug.Print XMLDoc.getElementsByTagName("Product").Item(0).BaseName
Dim i As Integer
For i = 0 To XMLDoc.getElementsByTagName("Measure").Length - 1
Debug.Print "type: "; XMLDoc.getElementsByTagName("Measure")(i).ChildNodes(0).Text,
Debug.Print XMLDoc.getElementsByTagName("Measure")(i).ChildNodes(1).Text,
Debug.Print XMLDoc.getElementsByTagName("Measure")(i).ChildNodes(2).Text
Next i
End Subhttps://stackoverflow.com/questions/46025167
复制相似问题