Objective
XML organizes data in a tree of elements with tags, attributes and text. The xml.etree.ElementTree module turns them into objects you can walk.
Instructions
- The input is a line with an XML document. It contains
itemelements (at any level) with the attributeprice(decimal) and, optionally,qty(integer, 1 if missing). - Show the total of
price * qtywith 2 decimals. Usefromstringanditer.
<shop><item price="2.5" qty="2"/><item price="1.25"/></shop>
6.25
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise