isogeo_xml_toolbelt.utils.xml_utils module

Isogeo XML Fixer - Metadata

Purpose: Read a metadata stored into XML ISO 19110 as an object Authors: Isogeo, inspired by the work did by GeoBretagne on mdchecker Python: 3.6.x

class isogeo_xml_toolbelt.utils.xml_utils.XmlUtils[source]

Bases: object

Common methods used to parse XML files.

parse_string_for_max_date(dates_as_str: str)[source]

Parse string with multiple dates to extract the most recent one. Used to get the latest modification date.

Parameters:dates_as_str (str) – string containing dates
xmlGetTextNodes(doc: lxml.etree._ElementTree, xpath: str, namespaces: dict)[source]

Shorthand to retrieve serialized text nodes matching a specific xpath.

Parameters:
  • doc (lxml.etree._ElementTree) – XML element to parse
  • xpath (str) – Xpath to reach
  • namespaces (dict) – XML namespaces like lxml.etree.getroot().nsmap
xmlGetTextTag(doc: lxml.etree._ElementTree, xpath: str, namespaces: dict, key: str)[source]

Function to get information in tag when information isn’t in nodes matching a specific xpath.

Parameters:
  • doc (lxml.etree._ElementTree) – XML element to parse
  • xpath (str) – Xpath to reach
  • namespaces (dict) – XML namespaces like ‘lxml.etree.getroot().nsmap’

:param key : XML key to find like ‘codeListValue’