[code.view]

[top] / python / PyMOTW / xml / etree / ElementTree / ElementTree_extend_node.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, SubElement, tostring, XML
     from ElementTree_pretty import prettify
     
     top = Element('top')
     
     parent = SubElement(top, 'parent')
     
     children = XML('''<root><child num="0" /><child num="1" /><child num="2" /></root> ''')
     parent.extend(children)
     
     print prettify(top)
     
     

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

contact | logmethods.com