Parsing XML
We'll cover the following...
Press + to interact
import xml.etree.ElementTree as etree #①tree = etree.parse('feed.xml') #②root = tree.getroot() #③root #④#<Element {http://www.w3.org/2005/Atom}feed at cd1eb0>
① The ElementTree library is part of the Python standard library, in xml.etree.ElementTree
.
② The primary entry point for the ElementTree library is the parse()
function, which can take a filename or a file-like object. This function parses the entire document at once. If memory is tight, there are ways to parse an xml ...