0
我有一個在VBScript中循環遍歷文件並返回結果的For Each
循環。每個循環與計數器
的代碼是:
Sub IterateSearch(FolderPath)
On Error Resume Next
Set fldr = fso.GetFolder(FolderPath)
Set Fls = fldr.files
For Each thing in Fls
sFSpec = FSO.GetAbsolutePathName(thing)
objMSXML.async = True
objMSXML.load sFSpec
If 0 = objMSXML.parseError Then
Dim sXPath : sXPath = "//*[local-name()='namespace']/*[local-name()='querySubject']/*[local-name()='queryItem'][contains(., '"& searchTerm &"')]/ancestor-or-self::*/*[local-name()='name' and @locale='en']"
Dim querySubject : Set querySubject = objMSXML.selectSingleNode(sXPath)
path.innerHtml = path.innerHtml & thing.path &"<br>"
If querySubject Is Nothing Then
MsgBox sXPath, "failed"
Else
For Each node In objMSXML.selectNodes(sXPath)
xmldoc.innerHtml = xmldoc.innerHtml & node.text & " " & "<br>"
' ObjOutFile.WriteLine Linenum & " " & thing.path
Next
' xmldoc.innerHtml = xmldoc.innerHtml & "<br><br>"
End If
Else
MsgBox objMSXML.parseError.reason
End If
Next
Set fldrs = fldr.subfolders
For Each thing in fldrs
IterateSearch thing.path
Next
End Sub
在它打印多個結果的情況下:
> - File Path 1 > - File Path 2 > - File Paht 3 - result set 1 - result set 2 - result set 3
我想要實現它,其導致應打印像這樣的方式:
> 1. File Path 1 - Result Set 1 > 2. File Path 2 - Result Set 2 > 3. File Paht 3 - Result Set 3
我想我需要調整循環和實現計數器來打印迭代次數。請建議。