
April 18th, 2012, 03:03 PM
|
|
Registered User
|
|
Join Date: Apr 2012
Posts: 1
Time spent in forums: 11 m 10 sec
Reputation Power: 0
|
|
|
XML editing: adding elements to xml lists
To start, I have almost zero experience with XML scripting/language but do have programming skills with other languages... this is something i have taken on at the behest of a colleague since it seems i am the only one with any programming knowledge... I was wondering if it is possible to take an xml list and using a sed,awk or perl script pass it a list of xml elements(plugin names) and insert a value(session name) keeping within the formatting rules... so the final command would look like
Code:
$xml_edit file.xml plugin_list.txt SESSION3
plugin_list.txt would contain the values:
CopyAtValidation
CopyAtFinish
Given a snippet of file.xml:
Code:
<plugin name="CopyAtValidation"
<plugin-filter code="some_filter.java">
<param name="SessionName" value="
SESSION1,
SESSION2"/>
</plugin-filter>
</plugin>
<plugin name="CopyAtStart"
<plugin-filter code="some_filter.java">
<param name="SessionName" value="
SESSION1,
SESSION2"/>
</plugin-filter>
</plugin>
<plugin name="CopyAtFinish"
<plugin-filter code="some_filter.java">
<param name="SessionName" value="
SESSION1,
SESSION2"/>
</plugin-filter>
</plugin>
I would like to add the value of SESSION3 to plugins CopyAtValidation and CopyAtFinish only so the final result looks like:
Code:
<plugin name="CopyAtValidation"
<plugin-filter code="some_filter.java">
<param name="SessionName" value="
SESSION1,
SESSION2,
SESSION3"/>
</plugin-filter>
</plugin>
<plugin name="CopyAtStart"
<plugin-filter code="some_filter.java">
<param name="SessionName" value="
SESSION1,
SESSION2"/>
</plugin-filter>
</plugin>
<plugin name="CopyAtFinish"
<plugin-filter code="some_filter.java">
<param name="SessionName" value="
SESSION1,
SESSION2,
SESSION3"/>
</plugin-filter>
</plugin>
I do want to point out that when you do insert the new values you have to add a comma to the end of the line of the previous value... namely SESSION2 otherwise this wont work.
|