MCPcopy Create free account
hub / github.com/STIXProject/python-stix / main

Function main

examples/xml2object.py:17–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15
16
17def main():
18 FILENAME = 'sample.xml'
19
20 # Parse input file
21 stix_package = STIXPackage.from_xml(FILENAME)
22
23 # Convert STIXPackage to a Python dictionary via the to_dict() method.
24 stix_dict = stix_package.to_dict()
25
26 # Print the dictionary!
27 pprint(stix_dict)
28
29 # Convert the first STIXPackage dictionary into another STIXPackage via
30 # the from_dict() method.
31 stix_package_two = STIXPackage.from_dict(stix_dict)
32
33 # Serialize the new STIXPackage object to XML
34 xml = stix_package_two.to_xml()
35
36 # Print the XML!
37 print(xml)
38
39if __name__ == '__main__':
40 main()

Callers 1

xml2object.pyFile · 0.70

Calls 4

from_xmlMethod · 0.80
to_dictMethod · 0.45
from_dictMethod · 0.45
to_xmlMethod · 0.45

Tested by

no test coverage detected