How to delete duplicate at looping

barneau

New Member
From Replace tags into symbol by elementree I wrote updated code:\[code\]import xml.etree.ElementTree as ETtree = ET.parse("1.xml") pattern = tree.findall('rule//')for child in pattern: if child.tag == 'word': print "%s" % child.text, elif child.tag == 'marker': print "(", for subchild in child: if subchild.tag == 'word': print "%s" % subchild.text, print ")",\[/code\]But I'm not sure about how to delete text in higher hierarchy, like:\[code\]if child.tag == 'word' and child.text != subchild.text:\[/code\]Currently result is:\[quote\] I need more ( money ) money now\[/quote\]But required is:\[quote\] I need more (money) now\[/quote\]
 
Back
Top