[code.view]

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

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
     #
     """Dump the OPML in plain text
     """
     #end_pymotw_header
     
     from xml.etree import ElementTree
     
     with open('data.xml', 'rt') as f:
         tree = ElementTree.parse(f)
     
     for path in [ './child', './child_with_tail' ]:
         node = tree.find(path)
         print node.tag
         print '  child node text:', node.text
         print '  and tail text  :', node.tail
     

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

contact | logmethods.com