1. Lars Yencken
  2. iterxml

Commits

Lars Yencken  committed 88f37ad

Clears up example

  • Participants
  • Parent commits 10eba3c
  • Branches default

Comments (0)

Files changed (1)

File Home.wiki

View file
  • Ignore whitespace
 $ sudo easy_install iterxml
 }}}
 
-Once that's done, we can start using it. For comparison, let's see what you might naturally do using built-in python libraries. For fun, let's assume the file is compressed with bz2 (large XML files compress well!).
+Once that's done, we can start using it. For comparison, let's see what you might naturally do using built-in python libraries. For fun, let's assume the file is compressed with bz2 (large XML files compress well!), and that each doc has a {{{<title>}}} node whose contents we want to print.
 
 {{{
 #!python
 
 istream = bz2.BZ2File('my_huge_file.xml.bz2', 'r')
 root = ElementTree.parse(istream).getroot()
-for node in root.findall('doc'):
+for doc in root.findall('doc'):
     print doc.find('title').text
 }}}