[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: On the promotion and demotion of information items (was Re


ixmldomnode vbscript
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@l...
Sent: 3/6/2003 7:48 AM
Subject: RE:  On the promotion and demotion of information items
(was Re:  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@d...]
Sent: Thu 3/6/2003 5:04 AM
To: Dare Obasanjo
Cc: Alaric B. Snell; Rick Jelliffe; xml-dev@l...
Subject: Re:  On the promotion and demotion of information
items (was Re:  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>

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.