# -*- coding: utf-8 -*- """ obsapi: helper module ~~~~~~~~~~~~~~~~~~~~~ This module contains helper functions :copyright: Copyright (c) 2020 Scott Bahling, SUSE Linux GmbH :license: GPL-2.0, see COPYING for details """ from io import BytesIO from lxml import etree def xml2etree(xml): try: if not isinstance(xml, bytes): xml = xml.encode('utf-8') parser = etree.XMLParser(remove_blank_text=True) return etree.parse(BytesIO(xml), parser).xpath('.')[0] except Exception as e: raise e