"Sax" is an XML parser that operates element by element, line by line. MiniDom sucks up an entire XML file, holds it in memory, and lets you work with it. Sax, on the other hand, emits events as it goes step by step through the file. '''NOTE''': A similarly fast but much simpler way to extract information from an XML document in an event-driven, memory efficient fashion is [[http://docs.python.org/library/xml.etree.elementtree.html#xml.etree.ElementTree.iterparse | ElementTree.iterparse()]]. == Example == {{{ #!python import xml.sax class InkscapeSvgHandler(xml.sax.ContentHandler): def startElement(self, name, attrs): if name == "svg": for (k,v) in attrs.items(): print k + " " + v parser = xml.sax.make_parser() parser.setContentHandler(InkscapeSvgHandler()) parser.parse(open("svg.xml","r")) }}} == Links == * HtmlParser -- similar module, tailored to HTML interpretation * [[http://docs.python.org/lib/module-xml.sax.html|Python Library Reference, xml.sax]] -- API documentation * [[http://www.rexx.com/~dkuhlman/pyxmlfaq.html|Python XML FAQ and How-to]] -- describes sax & MiniDom * [[http://pyxml.sourceforge.net/topics/howto/section-SAX.html|SAX: The Simple API for XML]] -- wordy tutorial * [[http://www-106.ibm.com/developerworks/linux/library/l-pxml.html|Charming Python:Revisiting XML tools for Python]] -- kind of old * [[http://www.xml.com/pub/a/2003/03/12/py-xml.html|Usings SAX for Proper XML Output]]