from genshi.template import MarkupTemplate

print MarkupTemplate('''
<doc xmlns:py="http://genshi.edgewall.org/">

<py:match path="div[@id='hello']">
    ${select('.')}
    <div id="goodbye"></div>
</py:match>

<div id="hello">Yo</div>

</doc>
''').generate()


