0
此腳本通過Windows子文件夾搜索XML文件。循環應該加載XML文件並執行一個操作,然後傳遞到下一個XML文件等VBS和XPATH處理多個XML文件
此行沒有被解釋我希望的方式:什麼是寫的正確方法
If oXML.load(objFile.name) Then
WScript.Echo "XML file loaded"
這個代碼?
這是完整的腳本。
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "C:\test_env"
set oXML = CreateObject("Msxml2.DOMDocument")
oXML.async = "false"
Set objFolder = objFSO.GetFolder(objStartFolder)
Wscript.Echo objFolder.Path
Set colFiles = objFolder.Files
For Each objFile in colFiles
Wscript.Echo objFile.Name
Next
Wscript.Echo
ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
If UCase(objFSO.GetExtensionName(objFile.name)) = "XML" Then
Wscript.Echo Subfolder.Path
Wscript.Echo objFile.Name
' LOAD THE XML FILE
If oXML.load(objFile.name) Then
WScript.Echo "XML loaded"
Else WScript.Echo "XML not loaded"
End If
End If
Next
ShowSubFolders Subfolder
Next
End Sub
在此先感謝。
是的!那就是訣竅。謝謝Ekkehard – Matthr0X 2012-08-07 15:17:16