gws.lib.xmlx.parser

XML parser.

Source code: gws.lib.xmlx.parser

Module Contents

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

Creates an IXmlElement object from a .xlm file.

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

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

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

  • normalize_namespaces

  • remove_namespaces – Removes all occurrences of namespaces.

Returns:

The IXmlElement object.

gws.lib.xmlx.parser.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 IXmlElement 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 IXmlElement object.

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

  • normalize_namespaces

  • remove_namespaces – Removes all occurrences of namespaces.

Returns:

The IXmlElement object.