Ok here is a script to try...
Paste the following into a text file and save it as xmlremovenodes.vbs
- Code: Select all
'xmlRemoveNodes
'Reads a text file in and deletes any lines containing the searchstring
'Run it using the cscript command...
'
'Usage:
'cscript xmlRemoveNodes.vbs <origfile> <newfile> <searchstring>
'
'If you want to delete an xml node then searchstring should be of the form "<nodename>" (inc. quotes)
'e.g. cscript xmlRemoveNodes.vbs "orig.xml" "new.xml" "<xmlnode>"
'
' by m_ski on xlobby.com
' 18th May 2006
Option Explicit
'On Error Resume Next
Dim objFSO
Dim objFromFile
Dim objToFile
Dim strLine
Dim commandLineArgs
Dim FromFile
Dim ToFile
Dim searchstring
wscript.echo "xmlRemoveNodes - by m_ski on xlobby.com"
wscript.echo "Usage: cscript xmlremoveNodes <origfile> <newfile> <searchstring>"
wscript.echo "e.g. cscript xmlRemoveNodes.vbs " & chr(34) & "orig.xml" & chr(34) & _
" " & chr(34) & "new.xml" & chr(34) & " " & chr(34) & "<xmlnode>" & chr(34)
'
' Get command line arguments
set commandLineArgs = WScript.Arguments
if commandLineArgs.length = 3 then
FromFile = commandLineArgs(0)
ToFile = commandLineArgs(1)
searchstring = commandLineArgs(2)
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFromFile = objFSO.OpenTextFile(FromFile, ForReading)
Set objToFile = objFSO.OpenTextFile(ToFile, ForWriting, True)
Do While objFromFile.AtEndOfStream = False
'read a line from the file
strLine = objFromFile.ReadLine
'Check if it contains the seacrh string
if InStr(strLine,searchstring) <> 0 then
'searchstring found so do not copy this line
wscript.echo "Deleted Line: " & strLine
else
'line does not contain searchstring so copy this line to the new file
objToFile.WriteLine strLine
end if
Loop
objFromFile.Close
objToFile.Close
Set objFromFile = Nothing
Set objToFile = Nothing
else
wscript.echo "Incorrect usage - must be 3 arguments"
end if
This script will take in a xlobby xml database file and output a new one omitting any lines containing the searchstring specified.
After the script has created the new file you will have to rename the old one to something else and rename the new one to the name of the original file, and then refresh the database. This can all be done automatically with an xlobby event.
Syntax is;
- Code: Select all
cscript xmlremovenodes.vbs <orig file> <new file> <variable to remove>
I advise you to surround each argument in quotes and specify the xmlnode like this - "<flag>".
Let me know if it works OK.