Replace tags into symbol by elementree

Nicko22

New Member
I have xml like this:\[code\]<rule> <word>I</word> <word>need</word> <word>more</word> <marker> <word>money</word> </marker> <word>now</word></rule>\[/code\]I can get the text by:\[code\] import xml.etree.ElementTree as ET tree = ET.parse("1.xml") for rule in tree.iter("rule"): for word in rule.iter("word"): print "%s" % word.text,\[/code\]And I'll get:\[code\]I need more money now\[/code\]How can I replace marker tags to ( and /marker to ).In other words result must be:\[code\]I need more (money) now\[/code\]Is it possible by elementtree? Thanks in advance!
 
Back
Top