Script to replace XML attribute value in multiple elements?
Forgive my ignorance, maybe this is simple but... I have an XML file containing info on multiple clips listed as follows:
<clip name="CLIP 1" duration="2615800/2400s" start="17990s" format="r1" tcFormat="NDF">
<video offset="17990s" ref="r6" duration="2615800/2400s" start="17990s">
<audio lane="-3" offset="17990s" ref="r6" srcID="3" duration="784740000/720000s" start="17990s" role="dialogue" srcCh="1, 2"/>
<audio lane="-2" offset="17990s" ref="r6" srcID="2" duration="784740000/720000s" start="17990s" role="dialogue" srcCh="1, 2"/>
<audio lane="-1" offset="17990s" ref="r6" duration="784740000/720000s" start="17990s" role="dialogue" srcCh="1, 2"/>
</video>
<keyword start="17990s" duration="2615800/2400s" value="Rough Mix 4_10"/>
</clip>
<clip name="CLIP 2".... etc.
Every clip (could be 4, could be 100) has the same "audio lane" attributes (1,2,3), and the same "role" attributes (dialogue). all other attributes are different for each clip in the XML.
What I'd like to do is, for each audio lane in every clip in the XML, change the the "role" attribute, and leave everything else alone. In a perfect world, I'd have a dialog pop up the listed the audio lanes, and a text box to enter the text I'd like to replace the existing role attribute in every instance of each lane. So all the audio lanes for every clip would change. Using etc Edit, Text Wrangler... something like that? I'd end up with something like the following:
<audio lane="-3" offset="17990s" ref="r6" srcID="3" duration="784740000/720000s" start="17990s" role="ROLE_C" srcCh="1, 2"/>
<audio lane="-2" offset="17990s" ref="r6" srcID="2" duration="784740000/720000s" start="17990s" role="ROLE_B" srcCh="1, 2"/>
<audio lane="-1" offset="17990s" ref="r6" duration="784740000/720000s" start="17990s" role="ROLE_A" srcCh="1, 2"/>
If the role attributes were all different, then I could just do a find and replace for the attributes, but since; they're the same for every audio lane, I'm clueless. Knowing that I'm clueless, I'm guessing there's a way to do this? I can do it manually, but if I had, say 100 clips in the XML, it'd be nice to automate it somehow. Thanks!
OS X Yosemite (10.10.4)