[
Lists Home |
Date Index |
Thread Index
]
The original poster requested Visual Basic or VBScript. So in Visual Basic
(not VB.NET and assuming a reference to msxml), the code would look like:
Sub RemoveMyAppSettings()
Dim configdom As DOMDocument40
Dim DocLoaded As Boolean
Dim NodeToDelete As IXMLDOMNode
Dim CurrentNode As IXMLDOMNode
Dim Parent As IXMLDOMNode
Set configdom = New DOMDocument40
DocLoaded = configdom.Load("C:\machine.config.txt")
If DocLoaded Then
Set CurrentNode =
configdom.selectSingleNode("//comment()[contains(.,'Start xxxx.Net')]")
Set NodeToDelete = CurrentNode.ParentNode
Set Parent = CurrentNode.ParentNode
While NodeToDelete.nodeTypedValue <> " End xxxx.Net "
Set NodeToDelete = CurrentNode
Set CurrentNode = CurrentNode.nextSibling
Parent.removeChild NodeToDelete
Wend
configdom.Save ("C:\machine.config.new.txt")
End If
End Sub
-----Original Message-----
From: Dare Obasanjo
To: Bill de hÓra
Cc: Alaric B. Snell; Rick Jelliffe; xml-dev@lists.xml.org
Sent: 3/6/2003 7:48 AM
Subject: RE: [xml-dev] On the promotion and demotion of information items
(was Re: [xml-dev] RE: Take 2 - How do you replace comments from XML?)
using System;
using System.Xml;
public class Test{
public static void Main(string[] args){
XmlDocument doc = new XmlDocument();
doc.Load("config.xml");
XmlNode curr = doc.SelectSingleNode("//comment()[contains(.,'Start
xxxx.Net')]");
XmlNode parent = curr.ParentNode, deleted;
do{
deleted = curr;
curr = curr.NextSibling;
parent.RemoveChild(deleted);
}while((deleted.NodeType != XmlNodeType.Comment) ||
(!deleted.Value.Equals(" End xxxx.Net ")));
Console.WriteLine(doc.OuterXml);
}
}
________________________________
From: Bill de hÓra [mailto:bill@dehora.net]
Sent: Thu 3/6/2003 5:04 AM
To: Dare Obasanjo
Cc: Alaric B. Snell; Rick Jelliffe; xml-dev@lists.xml.org
Subject: Re: [xml-dev] On the promotion and demotion of information
items (was Re: [xml-dev] RE: Take 2 - How do you replace comments from
XML?)
Like I said, if you have useful advice on processing this file, I'm
sure the OP would like to hear it (I certainly would).
Bill de hÓra
-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>
The list archives are at http://lists.xml.org/archives/xml-dev/
To subscribe or unsubscribe from this list use the subscription
manager: <http://lists.xml.org/ob/adm.pl>
|