Lecture 15: November 19, 2019
Reading
: §13–13.3
Due
: Homework 4, due on November 25 at 11:59pm
What is XML?
Tree structure
Elements, tags, attributes, and attribute values
Example:
sample1.xml
Python and XML [
basic-xml.py
]
xml.etree.ElementTree
Parsing the tree from file input (
ET.parse()
), from a string (
ET.fromstring()
)
Referring to elements
Accessing tag names, attributes
Finding nodes in the tree
Dumping, writing the tree
Removing an element and its descendants
Changing an element’s attribute
Setting attributes
Example: prettyprinting XML [
xmlpp.py
]
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email:
[email protected]
MISSING TITLE
Version of November 18, 2019 at 8:41PM
You can also obtain a PDF version of this.