File Parsing and Editing Help
Jay Vaughan
EMAIL HIDDEN
Thu Dec 10 08:28:43 CET 2009
> Meekly asking for some crawling advice so some day I might walk.
ADVICE, read carefully, FILES attached:
boko:mpxml j$ cat testdata.xml
<Parameter effectType="MultiTap" effectID="114" paramType="INT"
paramID="35" default="0" minimum="0" maximum="8" precision="0" unit=""
numVals="9" item0="QUAD-TAP" item1="PLEX DELAY" item2="PLEX DETUNE"
item3="PLEX SHIFT" item4="BAND DELAY" item5="QUAD-SERIES" item6="TEN-
TAPDLY" item7="RHYTHM TAP" item8="DIFFUSOR"></Parameter>
boko:mpxml j$ cat test.py
from xml.dom import minidom
xmldoc = minidom.parse('testdata.xml')
mp_params = xmldoc.getElementsByTagName('Parameter')
for mp_param in mp_params:
numval = mp_param.attributes["maximum"]
for i in range(int(numval.value)):
a = mp_param.attributes["item" + str(i)]
print a.name
a.value = a.value.title()
print a.value
print xmldoc.toprettyxml()
fp = open("newdata.xml", "w")
xmldoc.writexml(fp, " ", "", "\n", "UTF-8")
boko:mpxml j$ python test.py
item0
Quad-Tap
<?xml version="1.0" ?>
<Parameter default="0" effectID="114" effectType="MultiTap"
item0="Quad-Tap" item1="PLEX DELAY" item2="PLEX DETUNE" item3="PLEX
SHIFT" item4="BAND DELAY" item5="QUAD-SERIES" item6="TEN-TAPDLY"
item7="RHYTHM TAP" item8="DIFFUSOR" maximum="8" minimum="0"
numVals="9" paramID="35" paramType="INT" precision="0" unit=""/>
item1
Plex Delay
<?xml version="1.0" ?>
<Parameter default="0" effectID="114" effectType="MultiTap"
item0="Quad-Tap" item1="Plex Delay" item2="PLEX DETUNE" item3="PLEX
SHIFT" item4="BAND DELAY" item5="QUAD-SERIES" item6="TEN-TAPDLY"
item7="RHYTHM TAP" item8="DIFFUSOR" maximum="8" minimum="0"
numVals="9" paramID="35" paramType="INT" precision="0" unit=""/>
item2
Plex Detune
<?xml version="1.0" ?>
<Parameter default="0" effectID="114" effectType="MultiTap"
item0="Quad-Tap" item1="Plex Delay" item2="Plex Detune" item3="PLEX
SHIFT" item4="BAND DELAY" item5="QUAD-SERIES" item6="TEN-TAPDLY"
item7="RHYTHM TAP" item8="DIFFUSOR" maximum="8" minimum="0"
numVals="9" paramID="35" paramType="INT" precision="0" unit=""/>
item3
Plex Shift
<?xml version="1.0" ?>
<Parameter default="0" effectID="114" effectType="MultiTap"
item0="Quad-Tap" item1="Plex Delay" item2="Plex Detune" item3="Plex
Shift" item4="BAND DELAY" item5="QUAD-SERIES" item6="TEN-TAPDLY"
item7="RHYTHM TAP" item8="DIFFUSOR" maximum="8" minimum="0"
numVals="9" paramID="35" paramType="INT" precision="0" unit=""/>
item4
Band Delay
<?xml version="1.0" ?>
<Parameter default="0" effectID="114" effectType="MultiTap"
item0="Quad-Tap" item1="Plex Delay" item2="Plex Detune" item3="Plex
Shift" item4="Band Delay" item5="QUAD-SERIES" item6="TEN-TAPDLY"
item7="RHYTHM TAP" item8="DIFFUSOR" maximum="8" minimum="0"
numVals="9" paramID="35" paramType="INT" precision="0" unit=""/>
item5
Quad-Series
<?xml version="1.0" ?>
<Parameter default="0" effectID="114" effectType="MultiTap"
item0="Quad-Tap" item1="Plex Delay" item2="Plex Detune" item3="Plex
Shift" item4="Band Delay" item5="Quad-Series" item6="TEN-TAPDLY"
item7="RHYTHM TAP" item8="DIFFUSOR" maximum="8" minimum="0"
numVals="9" paramID="35" paramType="INT" precision="0" unit=""/>
item6
Ten-Tapdly
<?xml version="1.0" ?>
<Parameter default="0" effectID="114" effectType="MultiTap"
item0="Quad-Tap" item1="Plex Delay" item2="Plex Detune" item3="Plex
Shift" item4="Band Delay" item5="Quad-Series" item6="Ten-Tapdly"
item7="RHYTHM TAP" item8="DIFFUSOR" maximum="8" minimum="0"
numVals="9" paramID="35" paramType="INT" precision="0" unit=""/>
item7
Rhythm Tap
<?xml version="1.0" ?>
<Parameter default="0" effectID="114" effectType="MultiTap"
item0="Quad-Tap" item1="Plex Delay" item2="Plex Detune" item3="Plex
Shift" item4="Band Delay" item5="Quad-Series" item6="Ten-Tapdly"
item7="Rhythm Tap" item8="DIFFUSOR" maximum="8" minimum="0"
numVals="9" paramID="35" paramType="INT" precision="0" unit=""/>
item8
Diffusor
<?xml version="1.0" ?>
<Parameter default="0" effectID="114" effectType="MultiTap"
item0="Quad-Tap" item1="Plex Delay" item2="Plex Detune" item3="Plex
Shift" item4="Band Delay" item5="Quad-Series" item6="Ten-Tapdly"
item7="Rhythm Tap" item8="Diffusor" maximum="8" minimum="0"
numVals="9" paramID="35" paramType="INT" precision="0" unit=""/>
boko:mpxml j$ cat newdata.xml
<?xml version="1.0" encoding="UTF-8"?>
<Parameter default="0" effectID="114" effectType="MultiTap"
item0="Quad-Tap" item1="Plex Delay" item2="Plex Detune" item3="Plex
Shift" item4="Band Delay" item5="Quad-Series" item6="Ten-Tapdly"
item7="Rhythm Tap" item8="Diffusor" maximum="8" minimum="0"
numVals="9" paramID="35" paramType="INT" precision="0" unit=""/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: newdata.xml
Type: text/xml
Size: 361 bytes
Desc: not available
URL: <http://lists.music-bar.org/pipermail/music-bar/attachments/20091210/970b42f9/attachment-0002.xml>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.py
Type: text/x-python-script
Size: 438 bytes
Desc: not available
URL: <http://lists.music-bar.org/pipermail/music-bar/attachments/20091210/970b42f9/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testdata.xml
Type: text/xml
Size: 335 bytes
Desc: not available
URL: <http://lists.music-bar.org/pipermail/music-bar/attachments/20091210/970b42f9/attachment-0003.xml>
-------------- next part --------------
;
--
Jay Vaughan
More information about the music-bar
mailing list