Skip to content

Commit e77e7c6

Browse files
committed
Fixes #89: Remove bug from xmlToJson method.
Previously, our xmlToJson method was returning error: Global name "fromstring" is not defined. cause it is method of lmxl.etree and should be called using lmxl.etree object. This commit fixes this issue. - Import lmxl.etree module and then call method "fromstring". - Add lmxl dependency in requirements file.
1 parent d35dd21 commit e77e7c6

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

loklak.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import re
99
import requests
1010
from xmljson import badgerfish as bf
11+
import lxml.etree as et
1112
from json import dumps
1213
import csv
1314

@@ -75,7 +76,7 @@ def xmlToJson(self, xmlData = None):
7576
"""Convert XML to JSON as the service."""
7677
jsonData = ''
7778
if xmlData:
78-
jsonData = dumps(bf.data(fromstring(xmlData)))
79+
jsonData = dumps(bf.data(et.fromstring(xmlData)))
7980
return jsonData
8081

8182
def csvToJson(self, csvData = None, fieldnamesList = None):

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
requests==2.16.0
22
xmljson==0.1.9
3+
lxml==4.1.1

0 commit comments

Comments
 (0)