I'm writing a function in vba which can take in string parameters, and use it in xPath
thus query specificed data.
Public Function GetVal(ByVal refNum As String, ByVal jobNum As String, ByVal readingNum As String, ByVal dataName As String) As String
Dim xDoc As MSXML2.DOMDocument
Dim xmlFilePath As String: xmlFilePath = ThisWorkbook.Path & "\1.xml"
Dim apath as String
If Not xDoc.Load(xmlFilePath) Then
MsgBox ("Failed to load XML file."), vbCritical, "Sub Aborted"
aPath = "//CasaPiezos[CasaPiezo/CasaPiezoRdg/'dataname'"
'above is line not working i replace the variable with string it works, but string name canot
'those quotes driving me crazy.....
GetVal = xDoc.SelectSingleNode(aPath).Text
NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
This topic has been locked.
1 reply Latest Post - 2012-09-25T17:08:39Z by SystemAdmin
Pinned topic problem pass string variable to a xPath in VBA
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2012-09-25T17:08:39Z at 2012-09-25T17:08:39Z by SystemAdmin