瀏覽代碼

add xml_to_json parser

sxoinas12 2 年之前
父節點
當前提交
c89c7210c0
共有 2 個文件被更改,包括 12 次插入0 次删除
  1. 10 0
      telecaster/telecaster/parsers/parse_xml_to_json.py
  2. 2 0
      telecaster/telecaster/parsers/skroutz_parser.py

+ 10 - 0
telecaster/telecaster/parsers/parse_xml_to_json.py

@@ -0,0 +1,10 @@
+def parse_xml_to_json(xml):
+    response = {}
+
+    for child in list(xml):
+        if len(list(child)) > 0:
+            response[child.tag] = parse_xml_to_json(child)
+        else:
+            response[child.tag] = child.text or ''
+
+    return response

+ 2 - 0
telecaster/telecaster/parsers/skroutz_parser.py

@@ -0,0 +1,2 @@
+class SkroutzParser(url):
+    pass