xml: xml data to parse. Can be an XMLResource instance, a file-like object a path to a file or a URI of a resource or an Element instance or an ElementTree instance or a string containing the XML data.
Returns:
str: JSON-String
"""
dict,errors=converter.convert_xml_to_json(xml)
dict,errors=converter.convert_xml_to_json(xml)
returnjson.dumps(dict)
returnjson.dumps(dict)
defXMLToDict(xml):
defXMLToDict(xml)->tuple[dict,list[Exception]]:
"""Deserialize XML to dict
Args:
xml: xml data to parse. Can be an XMLResource instance, a file-like object a path to a file or a URI of a resource or an Element instance or an ElementTree instance or a string containing the XML data.
Returns:
tuple[dict, list[Exception]]: data as dict; list of exceptions that occurred during parsing
"""
dict,errors=converter.convert_xml_to_json(xml)
dict,errors=converter.convert_xml_to_json(xml)
returndict,errors
returndict,errors
defJSONToXML(jsonData):
defJSONToXML(jsonData:str)->str:
"""Serialize data from JSON format to XML
Args:
jsonData (str): the data that has to be encoded to XML
tuple[str, ElementTree.ElementTree, list[Exception]]: string containing the XML; ElementTree representation of the XML; and list of exceptions that occurred during serialization