Block 43: XML Parsing
Parse structured XML data using Python's xml.etree module.
Concepts
- xml.etree.ElementTree basics
- tree.getroot(), root.findall(), element.get()
- Iterating over child elements
- Extracting attributes and text
Code Examples
See exercise below.
Exercise
Parse a small XML file (e.g., RSS feed or sample data) and extract all title and link elements. Convert extracted XML data to a pandas DataFrame.
Homework
Compare XML and JSON as data formats: pros and cons of each.