Version: 1.2.0.0
stix.utils.parser Module¶
Classes¶
- class stix.utils.parser.UnsupportedVersionError(message, expected=None, found=None)¶
Bases: exceptions.Exception
Raised when a parsed STIX document contains a version that is not supported by this verison of python-stix.
- class stix.utils.parser.UnknownVersionError¶
Bases: exceptions.Exception
Raised when a parsed STIX document contains no version information.
- stix.utils.parser.UnsupportedRootElement¶
alias of UnsupportedRootElementError
- class stix.utils.parser.EntityParser¶
Bases: object
- parse_xml(xml_file, check_version=True, check_root=True, encoding=None)¶
Creates a python-stix STIXPackage object from the supplied xml_file.
Parameters: - xml_file – A filename/path or a file-like object representing a STIX instance document
- check_version – Inspect the version before parsing.
- check_root – Inspect the root element before parsing.
- encoding – The character encoding of the input xml_file. If None, an attempt will be made to determine the input character encoding.
Raises: - UnknownVersionError – If check_version is True and xml_file does not contain STIX version information.
- UnsupportedVersionError – If check_version is False and xml_file contains an unsupported STIX version.
- UnsupportedRootElement – If check_root is True and xml_file contains an invalid root element.
- parse_xml_to_obj(xml_file, check_version=True, check_root=True, encoding=None)¶
Creates a STIX binding object from the supplied xml file.
Parameters: - xml_file – A filename/path or a file-like object representing a STIX instance document
- check_version – Inspect the version before parsing.
- check_root – Inspect the root element before parsing.
- encoding – The character encoding of the input xml_file.
Raises: - UnknownVersionError – If check_version is True and xml_file does not contain STIX version information.
- UnsupportedVersionError – If check_version is False and xml_file contains an unsupported STIX version.
- UnsupportedRootElement – If check_root is True and xml_file contains an invalid root element.