Quick Start

A five-minute tour of pygixml: parse a string, read a value, and save it back out. For the full picture (navigating, XPath, streaming, the higher-level modules), see the pages linked in Next Steps below.

import pygixml

xml = '''
<library>
    <book id="1" category="fiction">
        <title>The Great Gatsby</title>
        <author>F. Scott Fitzgerald</author>
        <year>1925</year>
    </book>
</library>
'''

doc = pygixml.parse_string(xml)
root = doc.root

book = root.child("book")
print(book.attribute("id").value)        # 1
print(book.child("title").text())        # The Great Gatsby

# Create and save
doc = pygixml.XMLDocument()
root = doc.append_child("catalog")
root.append_child("item").set_value("Hello")
doc.save_file("output.xml")

Tip

Use ParseFlags to control parsing speed vs strictness. ParseFlags.MINIMAL skips escape processing and whitespace handling for maximum throughput. See Parse Flags for details.

Next Steps