3
我編寫了一個VBScript來刪除XML文件中的所有註釋。但它沒有正常工作。該腳本從.xml文件讀取,生成一個XML文件,該文件刪除註釋和另一個臨時XML文件。如何刪除XML註釋
Set argus = WScript.Arguments
If argus.Count = 0 Then
WScript.Quit
End If
Set fs = CreateObject("Scripting.FileSystemObject")
Set f_tu = fs.opentextfile(argus(0), 1, True)
Set f_tun = fs.opentextfile(argus(1), 2, True)
Set re_start = New RegExp
' re_start.Pattern="<!--.*-->"
re_start.Pattern="<!--"
' <!--.*|
re_start.IgnoreCase = False
re_start.Global = False
Setre_end = New RegExp
re_end.Pattern = "-->"
re_end.IgnoreCase = False
re_end.Global = False
Do While f_tu.AtEndOfStream <> True
data = f_tu.ReadLine
If re_start.Test(data) Then
Do While f_tu.AtEndOfStream <> True
data = f_tu.ReadLine
If re_end.Test(data) Then
Exit Do
End If
Loop
MsgBox data
Else
dataset = dataset+1
f_tun.WriteLine data
End If
Loop
f_tu.Close
f_tun.Close