我正在尝试调用一个函数。在函数内部,我正在读取一个 xml 文件并将值更改为其中一个节点。但它在行后退出功能sXmlFile = OpenXMLFile("\\common_automation\common_bin\" & sXmlFileName & ".xml")
单独测试时,函数内部的功能运行良好。但是我如何使控件进入整个功能而不退出。在为第一次调用完全执行函数中的语句之前,它对函数进行第二次调用。
x=replace_instrument_id(strIp,"newFund")
y=replace_instrument_id(strIp,"newBlock")
z=replace_instrument_id(strIp,"newSecRef")
Function replace_instrument_id(sCusip,sXmlFileName)
WScript.Echo"sCusip:" & sCusip
WScript.Echo"sXmlFileName:" & sXmlFileName
sXmlFile = OpenXMLFile("\\common_automation\common_bin\" & sXmlFileName & ".xml")
WScript.Echo "sXmlFile" & sXmlFile
strCusip = sCusip
Dim sNS : sNS = "xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'"
Dim oXDoc : Set oXDoc = CreateObject( "Msxml2.DOMDocument.6.0" )
Dim sXPath
if(sXmlFileName="newSecRef") Then
sXPath = "/NewDataSet/ReturningDataSet/live_ins_id"
Else
sXPath = "/NewDataSet/ReturningDataSet/ins_id"
End If
oXDoc.setProperty "SelectionLanguage", "XPath"
oXDoc.setProperty "SelectionNamespaces", sNS
oXDoc.async = False
oXDoc.loadXml sXmlFile
If 0 = oXDoc.ParseError Then
oXDoc.selectSingleNode(sXPath).text = strCusip
oXDoc.save "\common_automation\common_bin\"& sXmlFileName &".xml"
WScript.Echo oXDoc.selectSingleNode(sXPath).text
Else
WScript.Echo oXDoc.parseError.reason
End If
End Function
Function OpenXMLFile (filename)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(filename, 1)
thisline = objFile.ReadAll
objFile.Close
OpenXMLFile = thisline
End Function
我得到的输出是
sCusip:02R99BET7
sXmlFileName:newFund
sCusip:02R99BET7
sXmlFileName:newBlock
sCusip:02R99BET7
sXmlFileName:newSecRef