XML Parsing

Two common approaches

  • Event driven parsing (SAX)
  • Document Object Model (DOM)

SAX (Simple API for XML)

  • Read through the XML document
  • Trigger different functions for each element/entity as they are encountered.
  • Build up a data structure as you go

DOM

  • Entire XML document stored in memory as a big tree.
  • Access data by tree traversal.
  • Allows easy modification, manipulation of subtrees.
<<< O'Reilly OSCON 2001, New Features in Python 2, Slide 64
July 26, 2001, beazley@cs.uchicago.edu
>>>