用Python解析XML(1)

jieforest發表於2012-07-23
One of the common tasks I am given in my day job is to take some data format input and parse it to create a report or some other document. Today we'll look at taking some XML input, parsing it with the Python programming language and then creating a letter in PDF format using Reportlab, a 3rd party package for Python. Let's say my company receives an order for three items that I need to fulfill.
The XML for that could look like the following code:

CODE:

01.
02.
03.456789
04.789654
05.John Doe
06.123 Dickens Road
07.Johnston, IA 55555
08.
09.
10.
11.11123
12.Expo Dry Erase Pen
13.1.99
14.5
15.

16.
17.22245
18.Cisco IP Phone 7942
19.300
20.1
21.

22.
23.33378
24.Waste Basket
25.9.99
26.1
27.

28.

29.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/301743/viewspace-736308/,如需轉載,請註明出處,否則將追究法律責任。

相關文章