我如何获得节点列表?

时间:2017-11-09 15:29:18

标签: vbscript

尝试使用<EventID>1</EventID>列出节点但是我收到错误 它期待节点测试。

我有以下代码,但是当我运行它时,我收到以下错误:

error image

有人可以解释我做错了吗?

dim xml,node,nodes,Root,strNames
'Set xml =  CreateObject("Microsoft.XMLDOM")
Set xml =  CreateObject("MSXML2.DOMDocument.6.0")
xml.Async = False
xml.Load "C:\Test\Week\cr_history.txt"
xml.setProperty "SelectionLanguage","XPath"


For Each Node in xml.selectnodes("//DS001History/[@EventID='1']")
  strNames=Node.name
Next
msgbox strNames

1 个答案:

答案 0 :(得分:0)

您需要将xpath更改为> mydata <- read.table(file="file:///D:/Projects/Late Cretaceous/R Stuff/R Read In_Planktics.txt", header=TRUE,row.names=1, sep=",") > mydata.ra <- decorana(mydata, ira=1) Error in decorana(mydata, ira = 1) : all row sums must be >0 in the community matrix: remove empty sites 。这将在DS001History下获取值为1的所有EventID。请注意,我还使用了//DS001History/EventID[number(text())=1]来确保我只匹配数值。您也可以使用number()//DS001History/EventID[text()=1]

如果要获取值为1的所有EventID,您只需使用//DS001History/EventID[text()='1']即可。没有必要在xpath查询中给出父路径。

尝试以下代码

//EventID[text()=1]