I want to update

<MySettingsSettings enabled="false" logFilePath="E:\server.log" />

to

<MySettingsSettings enabled="true" logFilePath="D:\server.log" />

How can I do this through sed? or is there any other way to update in a windows server?

link|improve this question
2  
Ah, fun! Editing xml/html with regular expressions. Madness may be in your future. (stackoverflow.com/questions/1732348/…) – Zoredache Feb 18 '10 at 2:13
feedback

2 Answers

My suggestion, is that you use a real programming language that can actually parse and update XML/HTML documents properly. Using sed to update XML/HTML will probably fail in the long run.

link|improve this answer
+1 : Didn't notice this was a XML file. – Studer Feb 18 '10 at 2:25
I am just assuming it is xml/html. But it sure looks like it. – Zoredache Feb 18 '10 at 2:37
feedback

A simple substitution from your example can be done like this:

sed -e 's/enabled="true"/enabled="false"/g' -e 's/logFilePath="D:/logFilePath="C:/g' myfile.xml

However, I would agree with Zoredache's warning that unless you are only doing a very simple string replacement inside XML, you'd be better off with a language that has libraries available specifically built for parsing XML.

A great resource for a multitude of handy sed commands is the "sed one-liner" file:

http://sed.sourceforge.net/sed1line.txt

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.