我在包含組測試結果(如下所示)的XML文件中讀取:VBScript中取XML節點值和分配給變量
<?xml version="1.0"?>
<testsuite>
<build>
<run>
<test>
<index>1</index>
<id>1</id>
<description>Description 1</description>
<result>Pass</result>
</test>
<test>
<index>2</index>
<id>2</id>
<description>Description 2</description>
<result>Aborted</result>
</test>
<test>
<index>3</index>
<id>3</id>
<description>Description 3</description>
<result>Dependency</result>
</test>
<test>
<index>4</index>
<id>4</id>
<description>Description 4</description>
<result>Failed</result>
</test>
</run>
</build>
</testsuite>
我能成功地得到節點通過以下幾種:
strQuery = "/testsuite/build/run/test/ (id|result)"
Set nodeslist = xmlDoc.selectNodes(strQuery)
我知道使用for each循環搶節點值...
For Each objNode In nodeslist
'WHAT TO DO IN HERE...
Next
如何曾經,我現在停留在需要使用id及其相關結果的地步。本質上,我將採取這些信息並將結果上傳到測試系統,但目前我被困在如何循環訪問4個獨立的測試節點併爲每個測試節點挑選ID和結果,確保它們保持相互關聯即如果將它們分配給ID和RESULT等變量,那麼我可以在循環回去之前執行我的上載操作,並將它們重新分配給下一個測試節點中的值。
任何幫助非常感謝。
+0.49 - 你不能在節點集合上使用UBound();你必須從nodeslist.length –
開始,我*總是*犯這個錯誤。感謝您的支持。現在已經修復了。 –
+1花式XPath –