[code.view]

[top] / python / PyMOTW / xml / etree / ElementTree / ElementTree_extend.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
     #
     """Creating XML documents with lists of nodes
     """
     #end_pymotw_header
     
     from xml.etree.ElementTree import Element, tostring
     from ElementTree_pretty import prettify
     
     top = Element('top')
     
     children = [
         Element('child', num=str(i))
         for i in xrange(3)
         ]
     
     top.extend(children)
     
     print prettify(top)
     

[top] / python / PyMOTW / xml / etree / ElementTree / ElementTree_extend.py

contact | logmethods.com