[code.view]

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

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
     #
     """Embedded XML string with ID values
     """
     #end_pymotw_header
     
     from xml.etree.ElementTree import XMLID
     
     tree, id_map = XMLID('''
     <root>
       <group>
         <child id="a">This is child "a".</child>
         <child id="b">This is child "b".</child>
       </group>
       <group>
         <child id="c">This is child "c".</child>
       </group>
     </root>
     ''')
     
     for key, value in sorted(id_map.items()):
         print '%s = %s' % (key, value)
         
     

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

contact | logmethods.com