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