parser – XML Parser Module

class lazyxml.parser.Parser(encoding=None, unescape=False, strip_root=True, strip_attr=True, strip=True, errors='strict')

Simple xml parser

xml2dict(content)

Convert xml content to dict.

Warning

DEPRECATED: xml2dict() is deprecated. Please use xml2object() instead.

Deprecated since version 1.2.

xml2object(content)

Convert xml content to python object.

Parameters:content – xml content
Return type:dict

New in version 1.2.

xml_filter(content)

Filter and preprocess xml content

Parameters:content – xml content
Return type:str
static guess_xml_encoding(content)

Guess encoding from xml header declaration.

Parameters:content – xml content
Return type:str or None
static strip_xml_header(content)

Strip xml header

Parameters:content – xml content
Return type:str
classmethod parse(element)

Parse xml element.

Parameters:element – an Element instance
Return type:dict
classmethod parse_full(element)

Parse xml element include the node attributes.

Parameters:element – an Element instance
Return type:dict

New in version 1.2.1.

classmethod get_node(element)

Get node info.

Parse element and get the element tag info. Include tag name, value, attribute, namespace.

Parameters:element – an Element instance
Return type:dict
static split_namespace(tag)

Split tag namespace.

Parameters:tag – tag name
Returns:a pair of (namespace, tag)
Return type:tuple