#!/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) node = tree.find('./with_attributes') print node.tag for name, value in sorted(node.attrib.items()): print ' %-4s = "%s"' % (name, value)