Updating XML files using a shell script.
Hello everyone,
I continue to work on automating the update and deployment of a vendors WAR files, and have bumped into my next challenge... The vendor provides web.xml files have entries that look like this Code:
<context-param> |
You can try the n command of sed. Every time it encounters the pattern, it prints the current pattern (the matching line left untouched), empties the pattern space and read in the next line. At this point you can apply the substitution. Example:
Code:
$ sed '/siteminder.enabled/{n; s/false/true/}' file |
Quote:
|
As I and others have pointed out numerous times on these forums, sed is a poor tool to use for XML parsing and editing, since it will invariably depend on some kind of formatting that is subject to alteration by other tools and by the tool that creates the HTML (especially if that tool is a human). Instead, use a proper, robust XML parser such as one of the ones supported for Perl on CPAN.
--- rod. |
All times are GMT -5. The time now is 04:11 AM. |