xml_parser.py 255 B

1234567891011
  1. import xml.etree.ElementTree as ET
  2. tree = ET.parse('bookstore.xml')
  3. root = tree.getroot()
  4. for child in root:
  5. print(child.tag, child.attrib)
  6. for node in child:
  7. print(node.tag, node.attrib, node.text)
  8. for c in node:
  9. print(c.tag, c.attrib, c.text)