class documentation
XML parser for custom XML structures.
Parses arbitrary XML into a nested dictionary/list structure with tag names, attributes, cdata, and child tags.
| Method | __init__ |
Constructor. |
| Method | |
Handle character data from the XML parser. |
| Method | |
Handle an XML comment (ignored). |
| Method | |
Handle end of a CDATA section. |
| Method | |
Handle the end of an XML element. |
| Method | |
Handle end of a namespace declaration (ignored). |
| Method | |
Handle a processing instruction (ignored). |
| Method | |
Handle start of a CDATA section. |
| Method | |
Handle the start of an XML element. |
| Method | |
Handle start of a namespace declaration (ignored). |
| Method | parse |
Parse a given XML document into a nested tag structure. |
| Class Variable | i |
Undocumented |
| Instance Variable | b |
Undocumented |
| Instance Variable | d |
Undocumented |
Handle character data from the XML parser.
Appends character data to the current tag's cdata buffer.
| Parameters | |
| s | Character data string |
Handle the end of an XML element.
Pops the current tag, assembles it into a structured dict, and appends it to the parent tag's children.
| Parameters | |
| s | Element (tag) name |
| Raises | |
ParseError | If end tag does not match the expected start tag |
Handle a processing instruction (ignored).
| Parameters | |
| target:str | Processing instruction target |
| data:str | Processing instruction data |
Handle the start of an XML element.
Pushes a new tag dictionary onto the tag stack.
| Parameters | |
| s | Element (tag) name |
| d | Dictionary of element attributes |
Handle start of a namespace declaration (ignored).
| Parameters | |
| prefix:str | Namespace prefix |
| uri:str | Namespace URI |
Parse a given XML document into a nested tag structure.
| Parameters | |
| input:bytes or file-like | XML document as string or file object |
| Returns | |
| list | List of parsed tags |
| Raises | |
ParseError | If the XML document contains syntax errors |