gws.lib.xmlx

XML-related utilities and helpers.

Source code: gws.lib.xmlx

Submodules

Package Contents

exception gws.lib.xmlx.BuildError

Bases: Error

GWS error.

exception gws.lib.xmlx.Error

Bases: gws.Error

GWS error.

gws.lib.xmlx.from_path(path: str, case_insensitive: bool = False, compact_whitespace: bool = False, normalize_namespaces: bool = False, remove_namespaces: bool = False) gws.XmlElement

Creates an XmlElement object from a .xml file.

Parameters:
  • path – Path to the .xml file.

  • case_insensitive – If true tags will be written in lowercase into the XmlElement.

  • compact_whitespace – If true all whitespaces and newlines are omitted.

  • normalize_namespaces

  • remove_namespaces – Removes all occurrences of namespaces.

gws.lib.xmlx.from_string(inp: str | bytes, case_insensitive: bool = False, compact_whitespace: bool = False, remove_namespaces: bool = False, normalize_namespaces: bool = False) gws.XmlElement

Creates an XmlElement from a string or bytes.

Parameters:
  • inp – .xml file as a string or bytes.

  • case_insensitive – If true tags will be written in lowercase into the XmlElement.

  • compact_whitespace – If true all whitespaces and newlines are omitted.

  • normalize_namespaces

  • remove_namespaces – Removes all occurrences of namespaces.

exception gws.lib.xmlx.ParseError

Bases: Error

GWS error.

gws.lib.xmlx.tag(name: str, *args, **kwargs) gws.XmlElement

Build an XML element from arguments.

exception gws.lib.xmlx.WriteError

Bases: Error

GWS error.