Код:
Option Explicit
Dim strSourceFile
Dim strFromString, strToString
Dim objXMLDOMElement
Dim boolDeletion
If WScript.Arguments.Count = 1 Then
strSourceFile = WScript.Arguments.Item(0)
If WScript.CreateObject("Scripting.FileSystemObject").FileExists(strSourceFile) Then
strFromString = InputBox("From string") ' "Rinat-106 M"
strToString = InputBox("To string") ' "С нами: 3 года 2 месяца"
With WScript.CreateObject("Microsoft.XMLDOM")
.load(strSourceFile)
boolDeletion = False
For Each objXMLDOMElement In .selectNodes("/FictionBook/body/section/p")
If Not boolDeletion Then
If StrComp(objXMLDOMElement.text, strFromString, vbTextCompare) = 0 Then
objXMLDOMElement.parentNode.removeChild objXMLDOMElement
boolDeletion = True
End If
Else
objXMLDOMElement.parentNode.removeChild objXMLDOMElement
If StrComp(objXMLDOMElement.text, strToString, vbTextCompare) = 0 Then
boolDeletion = False
End If
End If
Next
.Save strSourceFile
End With
Else
WScript.Echo "Can't find source file [" & strSourceFile & "]."
WScript.Quit 2
End If
Else
WScript.Echo "Usage: cscript.exe //nologo """ & WScript.ScriptName & """ <Source file>"
WScript.Quit 1
End If
WScript.Quit 0