Skip to main content
100%

BeautifulSoup with XML

✓ Published0🌍 Public
VVioletVivirand
Last edited Feb 1, 2019
Created on Feb 1, 2019

This example demonstrates how to read, modify, and extend an XML document using BeautifulSoup’s XML parser. The code loads `template.xml`, then directly alters the text content of the `size.width` tag and appends a newly created `object` tag to the root annotation. Finally, it prints the updated document with `prettify()` for readable formatting. The example highlights BeautifulSoup’s `new_tag` and `append` APIs for programmatic XML manipulation, showing how to treat the document as a mutable tree structure.

AI-generated description

Similar vizzes