I have a big xml file with the following structure:
<items>
<item>
<a>id1</a>
<b>foo</b>
<c>1</c>
<d>1</d>
<e></e>
</item>
<item>
<a>id2</a>
<b>bar</b>
<c>1</c>
<d>1</d>
<e>3</e>
</item>
<item>
<a>id3</a>
<b>fum</b>
<c>1</c>
<d>1</d>
<e></e>
</item>
</items>
I would like to set the value of e
with a value which depends on the value of a
. So if the item
contains the value id1
for the property a
, e
should be set with 123
, if the property a
is id2
set it to 456
etc.
It's easy to use with a script language. I tried it with JavaScript (jQuery) in the dev tools of the Chrome browser but I was only able to read the values but not write them back. Maybe I'm just too tired... If anyone of you can help me which a script language of your choice (best would be you don't have to install anything) I would be glad!
Here is the small snippet I used so far:
$($.parseXML(xml)).find('chests_costs').children().each(function(i, o) {
if($(o).find('a').text() == 'id1') {
$(o).find('a').text('123')
}
});