xml parsing with lxml

John Gordon gordon at panix.com
Fri Oct 7 16:21:30 EDT 2016


In <622ea3b0-88b4-420b-89e0-9e7c6e866715 at googlegroups.com> Doug OLeary <dkoleary at olearycomputers.com> writes:

> >>> from lxml import etree
> >>> doc =3D etree.parse('config.xml')

> Now what?  For instance, how do I list the top level children of
> <domain>?

root = doc.getroot()
for child in root:
    print(child.tag)

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon at panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"




More information about the Python-list mailing list