Jump to content

VBS to edit XML file on desktop


PuppyOnTheRadio
 Share

Recommended Posts

Hey. I posted something at http://w3schools.invisionzone.com/index.php?showtopic=43927 that I need help with. I was looking for a VBS solution to delete lines of an XML doc (as though it were a text file) based upon lines above and below.It seems like a fairly straightforward idea, but I'm not that fantastic at VBS and thought someone may be able to work out a quicker way of doing this than I can.

Link to comment
Share on other sites

Okay - I've played with this in excel and VBA and have the bones of a script:

Sub Macro1()    Application.ScreenUpdating = False    Do	    If InStr(ActiveCell.Value, "<timestamp>") > 0 Then		    If Mid(ActiveCell.Value, 18, 4) < 2010 Then			    Do				    ActiveCell.Offset(-1, 0).Select			    Loop Until InStr(ActiveCell.Value, "<revision>") > 0			    Do				    Selection.Delete Shift:=xlUp			    Loop Until InStr(ActiveCell.Value, "</revision>") > 0			    Selection.Delete Shift:=xlUp		    Else			    ActiveCell.Offset(1, 0).Select		    End If	    Else		    If InStr(ActiveCell.Value, "<siteinfo>") > 0 Then			    Do				    Selection.Delete Shift:=xlUp			    Loop Until InStr(ActiveCell.Value, "</siteinfo>") > 0			    Selection.Delete Shift:=xlUp		    Else			    ActiveCell.Offset(1, 0).Select		    End If	    End If    Loop Until InStr(ActiveCell.Value, "</mediawiki>") > 0    Application.ScreenUpdating = TrueEnd Sub

I'd like to do the same with a VBS that will also:

  1. Open the XML as though it were a text file
  2. work on a line-by-line basis instead of a cell by cell basis

Who can bail me out here?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...