title: XPath count in VBScript
body: <p>I am trying to get the number of specific nodes in an XML file using the XPath count function, however, this keeps returning an error "An exception of type 'msxml3.dll: Expression does not return a DOM node."</p>
  
  <p>How do I get the return value from an XPath count using VBScript and MSXML DOM</p>
  
  <pre><code>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="&amp;homeId&amp;"])")
  Set awayGoals = oXML.SelectSingleNode("count(/SoccerMatch/Goals/Goal[@teamId="&amp;awayId&amp;"])")
  </code></pre>