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

Re: RE: Take 2 - How do you replace comments from XML?


replace machine.config
Dominica DeGrandis wrote:
> Ok -  I left out some important information in my request for help below.
> The file I'm working with is a MS .NETFramework system file under
> C:\WINNT\Microsoft.NET\Framework\v1.0.3705\CONFIG called machine.config.
> It's an XML file.   It uses comments to separate sections of configurations.
> I'm trying to replace custom configurations under the <appSettings> node
> that begins and ends with comments.

Ahh... misread your post, sorry. Then you probably want a line 
oriented thing to plonk in a magic marker tag


def insertMarkers(before, after):
     ifile = open("machine.config")
     ofile = open("machine-tmp.config", "w")

     for line in ifile:
             if line.find(before) != -1:
               ofile.write("<magic.marker>")

             ofile.write(line)

             if line.find(after) != -1:
               ofile.write("</magic.marker>")
     ifile.close()
     ofile.close()

if __name__ == "__main__":
   insertMarkers("Start xxxx.Net", "End xxxx.Net")


Now you can select the magic.marker blocks in machine-tmp.config, do 
whatever you like with that document, and write back to the original 
minus the tags. It [expletive deleted] for sure, but without knowing exactly what 
you're trying to do, are you certain that there isn't enough 
information in the XML (minus comments) to pick out what you need?

Bill de hÓra



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.