xml = """ This is the title
Name Description
Name Description
""" from meld3 import parse_xmlstring from meld3 import parse_htmlstring from StringIO import StringIO import sys root = parse_xmlstring(xml) root.findmeld('title').content('My document') root.findmeld('form1').attributes(action='./handler') data = ( {'name':'Boys', 'description':'Ugly'}, {'name':'Girls', 'description':'Pretty'}, ) iterator = root.findmeld('tr').repeat(data) for element, item in iterator: element.findmeld('td1').content(item['name']) element.findmeld('td2').content(item['description']) root.write_xhtml(sys.stdout)