I am trying to get the number of specific nodes in an XML file using the XPath count function, however this returns an "Type Exception" error msxml3.dll: the expression does not return a DOM node. "
How to get return value from XPath count using VBScript and MSXML DOM
Dim oXML
Dim homeId
Dim awayId
Dim homeGoals
Dim awayGoals
Set oXML = Server.CreateObject("Microsoft.XMLDOM")
oXML.async = false
oXML.SetProperty "SelectionLanguage", "XPath"
oXML.SetProperty "ServerHTTPRequest", True
oXML.validateOnParse = False
oXML.resolveExternals = False
fileName = "http://server:8090/data/results/m12345.xml")
oXML.load (fileName)
homeId = oXML.SelectSingleNode("/SoccerMatch/Team[@homeOrAway='Home']/@id").text
awayId = oXML.SelectSingleNode("/SoccerMatch/Team[@homeOrAway='Away']/@id").text
Set homeGoals = oXML.SelectSingleNode("count(/SoccerMatch/Goals/Goal[@teamId="&homeId&"])")
Set awayGoals = oXML.SelectSingleNode("count(/SoccerMatch/Goals/Goal[@teamId="&awayId&"])")
source
share