gws.tools.xml2

XML parser and generator.

The parser is expat-based. It returns Element instances.

The generator (as_string) accepts a Tag, which is simply a tuple of tag name, attributes (dict) and subtags (Tags).

exception gws.tools.xml2.Error[source]
gws.tools.xml2.tag(*args) → tuple[source]
gws.tools.xml2.as_string(p: Union[str, tuple, Element]) → str[source]
gws.tools.xml2.qname(namespace, tag)[source]
gws.tools.xml2.encode(v: str) → str[source]
class gws.tools.xml2.Attribute(qname, name, value)[source]
class gws.tools.xml2.Element[source]
as_tag()[source]
strip_ns()[source]
attr(key, default=None)[source]
attr_dict
get(path, default=None)[source]
all(path=None) → List[gws.tools.xml2.Element][source]
first(path=None, default=None) → gws.tools.xml2.Element[source]
get_text(path) → str[source]
gws.tools.xml2.from_path(path) → gws.tools.xml2.Element[source]
gws.tools.xml2.from_string(src) → gws.tools.xml2.Element[source]
gws.tools.xml2.peek(src)[source]
gws.tools.xml2.strip_before(text, el)[source]