xx

import os
import re
import xml.dom.minidom

dom = xml.dom.minidom.parse('xml.xml')
root = dom.documentElement
hellolist = root.getElementsByTagName('Hello')

for helloitem in hellolist:
print helloitem.getAttribute('x')
formale = helloitem.getElementsByTagName('Inter')
#print formale[0].firstChild.data
x = formale[0].firstChild.data
formalegroup = re.search(r'\[(.*)_Low\]\+\[(.*)_High\]', x)
if formalegroup == None:
continue
if helloitem.getAttribute('x') == formalegroup.group(1) and helloitem.getAttribute('x') == formalegroup.group(2):
print "ok"
print formalegroup.group(0)
print formalegroup.group(1)
print formalegroup.group(2)

 

 

 

<?xml version="1.0" encoding="utf-8"?>
<Main>
<Hello x="Count61" y="2">
<Inter>[Count61_Low]+[Count61_High]</Inter>

</Hello>

<Hello x="Count62" y="3">
<Inter>[Count62_Low]+[Count62_High]</Inter>

</Hello>
</Main>

posted @ 2015-09-14 22:49  露天坝  阅读(156)  评论(0编辑  收藏  举报