Tag: xmldom

VBA(Excel):读取类内的XML文件

这是简单而基本的,但我还没有得到它。 我有几行代码从XML文件中读取节点属性。 当我在Module 1中运行代码时,它工作正常。 Sub ParseSingleTestResult(resFile As String, testRow As Integer) Set oXMLFile = CreateObject("Microsoft.XMLDOM") oXMLFile.Load (resFile) 'Find the <ResultsSummary> node and the outcome attribute: Set resultNode = oXMLFile.SelectNodes("/TestRun/ResultSummary") Set Node_Attribute = oXMLFile.SelectNodes("/TestRun/ResultSummary") Attrib = Node_Attribute(0).getAttribute("outcome") Cells(testRow, 10) = Attrib End Sub 但是,类(正在处理工作簿超链接)中的完全相同的代码给出了这个错误: Run-time error '91': Object variable or With block variable not set 下面是类模块中的相同代码 […]

将多个xml节点提取到数组中而不循环

我有一个XML文件,看起来像这样: <rng> <col1> <row1>A</row1> <row2>B</row2> <row3>C</row3> <row4>D</row4> </col1> <col2> <row1>E</row1> <row2>F</row2> <row3>G</row3> <row4>H</row4> </col2> </rng> col节点有很多 ,每个包含几千行元素。 我想parsing出行元素的值,并最终把它们放到电子表格上。 我目前正在这样做,如下所示: ' get a list of the col elements (thi sits in a loop to go through them all) Set oXMLColNodeList = oXMLDoc.selectNodes("//saveStates/rng/*") ' Lop through each column For colNum = 1 To oXMLColNodeList.Length ' get all […]