0

関数を呼び出そうとしています。関数内で、xml ファイルを読み取り、値をノードの 1 つに変更しています。しかし、その行の後に関数を終了しますsXmlFile = OpenXMLFile("\\common_automation\common_bin\" & sXmlFileName & ".xml")

個別にテストしたときの関数内の機能は正常に機能しています。しかし、終了せずにコントロールを関数全体に移動させる方法。最初の呼び出しで関数内のステートメントを完全に実行する前に、関数への 2 回目の呼び出しを行います。

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
4

0 に答える 0