Lists Home |
Date Index |
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:
if line.find(after) != -1:
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 sucks 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