Jump to content

Code to edit a line in a XML file?


JayMan
 Share

Recommended Posts

Hi All,

I'm trying to come up with a nice/easy/elegant way to search through a text (XML) file looking for a string, and if the string is not found it should enter that line & save the file.

Here is a snippet of the XML file (.config file for a .Net application if it matters)

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    ~~~~junk removed from here~~~~
    </assemblyBinding>
    <gcConcurrent enabled="true"/>
    <generatePublisherEvidence enabled="false"/>
</runtime>

Basically I need to make sure the "<generatePublisherEvidence enabled="false"/>" line exists in the file... When it doesn't exist & the line is added, it is important that it is added directly under the "<gcConcurrent enabled="true"/>" line.

Any and all help will be much appreciated!

Thanks

Jay

Link to comment
Share on other sites

Take a look at this. XML DOM wrapper (COM)

Also next time you might want to use the search feature. It would of taken far less time to search instead of creating a topic and waiting for a reply.

Good Luck.

-Mike

Edited by P5ych0Gigabyte
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

  • 3 months later...

Sorry for my late reply... Got overloaded with other work! Now back to this issue...

I've had a look at that AU3 and like most of other peoples script I look at, it confuses the heck outa me lol

Sorry i'm a relative Noob at AutoIT...

Presumably I need to be working with the _XMLNodeExists? Any pointers would be good...

Also, is it possible to do this on a basic text file? I need to do the same thing (i.e. with the windows 'hosts' file... For some reason a bunch of computers have a corrupt character in this file and this is causing problems as any lines added after this character aren't being read by windows. Basically I wanna find this strange character & replace it with a carriage return...

Cheers

JayMan

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...