Asp.net 将字符串数组Fom XML读入VBA

Asp.net 将字符串数组Fom XML读入VBA,asp.net,xml,string,vba,web-services,Asp.net,Xml,String,Vba,Web Services,我有以下XML,它是某个WEB服务的结果 - 2016年5月16日至2016年5月20日 2016年5月20日至2016年5月23日 2016年5月23日-2016年5月27日 2016年5月27日至2016年5月30日 将从web服务返回的xml结果读取到xml文档中,并使用例如选择SingleNode来选择节点ArrayOfString。此节点具有namaspace,因此您还需要在xpath中使用名称空间。然后只需将所有子节点文本读取到此处声明为result的集合中即可。嗯 注意:添加对

我有以下XML,它是某个WEB服务的结果


-
2016年5月16日至2016年5月20日
2016年5月20日至2016年5月23日
2016年5月23日-2016年5月27日
2016年5月27日至2016年5月30日

将从web服务返回的xml结果读取到xml文档中,并使用例如
选择SingleNode
来选择节点
ArrayOfString
。此节点具有namaspace,因此您还需要在
xpath
中使用名称空间。然后只需将所有子节点文本读取到此处声明为
result
的集合中即可。嗯

注意:添加对Microsoft XML v6.0 dll的引用


我使用‘dee’的答案进行推断,但是读入一个列数为x的数组。下面之所以使用dNode,是因为webservices通常返回辅助元数据,其级别与数组中所需的实际值相同。因此,此时必须使用SelectSingleNode

xmlDoc.SetProperty "SelectionNamespaces", xmlNamespaces
Set xmlNodes = xmlDoc.SelectNodes("/myns:.../...")
rws = xmlNodes.length
cols = var '# of columns from the request sent or extrapolate this code to count children of a single node at the level necessary
ReDim xay(1 To rws, 1 To cols)

For Each xNode In xmlNodes
    r = r + 1
    For c = 1 To UBound(xay, 2)
        Set dNode = xNode.ChildNodes(c - 1)
        Set dNode = dNode.SelectSingleNode("myns:THE_VALUE")
        xay(r, c) = dNode.Text
    Next c
Next xNode
xmlDoc.SetProperty "SelectionNamespaces", xmlNamespaces
Set xmlNodes = xmlDoc.SelectNodes("/myns:.../...")
rws = xmlNodes.length
cols = var '# of columns from the request sent or extrapolate this code to count children of a single node at the level necessary
ReDim xay(1 To rws, 1 To cols)

For Each xNode In xmlNodes
    r = r + 1
    For c = 1 To UBound(xay, 2)
        Set dNode = xNode.ChildNodes(c - 1)
        Set dNode = dNode.SelectSingleNode("myns:THE_VALUE")
        xay(r, c) = dNode.Text
    Next c
Next xNode