[code.view]

[top] / python / PyMOTW / xml / etree / ElementTree / ElementTree_show_feed_urls.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('podcasts.opml', 'rt') as f:
         tree = ElementTree.parse(f)
     
     for node in tree.iter('outline'):
         name = node.attrib.get('text')
         url = node.attrib.get('xmlUrl')
         if name and url:
             print '  %s :: %s' % (name, url)
         else:
             print name
     

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

contact | logmethods.com