In this example, we'll update our game to use a DOM parser as opposed to a SAX parser. You should notice how the in-memory structure is built for us and we no longer have to maintain our own object graph. We'll reuse the same XML document for this example:
sax_explore.pyover to a new file named
import sys import random from xml.dom.minidom import parse
__metaclass__line, and the
__name__ == '__main__'section.
Adventureclass to contain the following Python code:
import sys import random from xml.dom.minidom import ...