Python lxml.etree.LxmlError() Examples

The following are 1 code examples of lxml.etree.LxmlError(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module lxml.etree , or try the search function .
Example #1
Source File: xml.py    From python-gvm with GNU General Public License v3.0 6 votes vote down vote up
def validate_xml_string(xml_string: str):
    """Checks if the passed string contains valid XML

    Raises a GvmError if the XML is invalid. Otherwise the function just
    returns.

    Arguments:
        xml_string: XML string to validate

    Raises:
        GvmError: The xml string did contain invalid XML

    """
    try:
        secET.fromstring(xml_string)
    except (DefusedXmlException, etree.LxmlError) as e:
        raise GvmError("Invalid XML", e) from e