Jump to content
PuppyOnTheRadio

VBS to edit XML file on desktop

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.

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...