xmlvbanodesdomdocumentselectnodes

Using a variable in selectsinglenodes ..... 'string construct' workaround (using VBA?)


So I'm trying to do something this

dim myOrderID As Integer
myOrderID = 1
Set Ordercount = objxmldoc.selectNodes("//order[orderid=myOrderID]")

....in other words, embed a variable in the selection criteria for selectNodes . From the googling I've done, apparently I can't (ref: XPath variable for searching attribute ), but I can perhaps use something called a string construct...I have no idea what that means ...or more to the point how I'd do it in VBA?!


Solution

  • Try:

    Set Ordercount = objxmldoc.selectNodes("//order[orderid=" & myOrderID & "]")