Outline for March 4, 2019
Reading
:
text
, §11
Homework: due March 8, 2018 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
Department of Computer Science
University of California at Davis
Davis, CA 95616-8562 USA
Last modified: Version of March 4, 2019 at 7:41AM
Winter Quarter 2019
You can get a PDF version of this