scrapinghub/js2xml

Issue when trying to parse string that is escaped

Closed this issue · 1 comments

import js2xml
import lxml.etree
js = """
var test = '124234' + 'asdasf' + '('events','event4')'
"""
jsxml = js2xml.parse(js)
print lxml.etree.tostring(jsxml, pretty_print=True)
File "", line unknown
SyntaxError: Unexpected token (ID, 'events') at 1:37 between LexToken(STRING,"'('",1,34) and LexToken(STRING,"','",1,43)

It works using raw strings:

import js2xml
import lxml.etree
js = r"""
var test = '124234' + 'asdasf' + '(\'events\',\'event4\')'
"""
jsxml = js2xml.parse(js)