12.11. The Invoice Printing Problem Solved Three Ways

In section 8.11.2, the pros and cons of event-driven XML processing were discussed. The section posed the question, How would you write a program to print invoices from the following document that has at least three item elements?

CD-ROM reference=12026.txt
<invoices>
      <invoice>
            <item name="shoes" cost="10.00"/>
            <item name="socks" cost="1.00"/>
      </invoice>
      <invoice>
            <item name="shoes" cost="10.00"/>
            <item name="socks" cost="1.00"/>
      </invoice>
      <invoice>
            <item name="shoes" cost="10.00"/>
            <item name="socks" cost="1.00"/>
            <item name="trousers" cost="100.00"/>
      </invoice>
      <invoice>
            <item name="shoes" cost="10.00"/>
      </invoice>
</invoices>

The Pyxie program below solves this problem with three different ...

Get XML Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.