diff --git a/docs/index.html b/docs/index.html index 9f15352..264194e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -123,6 +123,32 @@

Convert JSON and CSV

#id,name #12,Collins + + + + +

Convert JSON and xml

+
+
+        
+        from textbin.textbin import *
+        textbin_obj = textbin.Textbin()
+
+        #convert json to xml
+        json_data = { 'id' : 12 , 'name' : 'Collins' }
+        converted = textbin_obj.json_to_xml(json_data)
+        print(converted)
+
+        #Output 12Collins
+
+        #convert xml to  json
+        xml_data = "12Collins"
+        converted = textbin_obj.xml_to_json(xml_data)
+        print(converted)
+        print(converted)
+
+        #Output { 'id' : 12 , 'name' : 'Collins' }
+      
       
     
diff --git a/examples.py b/examples.py index 1d1e7b2..a3d5cbd 100644 --- a/examples.py +++ b/examples.py @@ -55,9 +55,16 @@ #convert json to xml print("convert json to xml") -json_list = [{ 'id' : 12 , 'name' : 'Collins' }] -converted = textbin_obj.json_to_xml(json_list) +json_data = { 'id' : 12 , 'name' : 'Collins' } +converted = textbin_obj.json_to_xml(json_data) print(converted) print("************************************************************\n") +#convert xml to json +print("convert xml to json") +xml_data = "12Collins" +converted = textbin_obj.xml_to_json(xml_data) +print(converted) + +print("************************************************************\n") diff --git a/pytextbin/__pycache__/pytextbin.cpython-311.pyc b/pytextbin/__pycache__/pytextbin.cpython-311.pyc index 9fd1a0c..8e26e4e 100644 Binary files a/pytextbin/__pycache__/pytextbin.cpython-311.pyc and b/pytextbin/__pycache__/pytextbin.cpython-311.pyc differ diff --git a/pytextbin/pytextbin.py b/pytextbin/pytextbin.py index 65e3c72..790b43b 100644 --- a/pytextbin/pytextbin.py +++ b/pytextbin/pytextbin.py @@ -184,7 +184,7 @@ def _element_to_dict(self, element: ET.Element) -> Union[dict, list]: if element: if element.attrib: return {element.tag: element.attrib} - children = element.getchildren() + children = element.get(self) if children: out = {} for child in children: