I'm trying to apply the MODSReader not to a xml-file (as in the examples provided) but rather on requests.get-responses I've tried transforming the xml-string into a file-like object using io.StringIO (which would be the usual way to deal with the issue in etree, I guess), but I'm getting a ValueError:
File "mods_parse.py", line 6, in <module>
MODSReader(io.StringIO(request_opac("pica.sys=j2017").text))
File "/home/alex/.local/lib/python3.6/site-packages/pymods/reader.py", line 58, in __init__
super(MODSReader, self).__init__(file_location, '{0}mods'.format(NAMESPACES['mods']), parser=mods_parser)
File "/home/alex/.local/lib/python3.6/site-packages/pymods/reader.py", line 27, in __init__
self.iterator = parse(file_location, parser=parser).iter(iter_elem)
File "/home/alex/.local/lib/python3.6/site-packages/pymods/reader.py", line 8, in parse
return etree.parse(source, parser=parser)
File "src/lxml/etree.pyx", line 3469, in lxml.etree.parse
File "src/lxml/parser.pxi", line 1856, in lxml.etree._parseDocument
File "src/lxml/parser.pxi", line 1871, in lxml.etree._parseMemoryDocument
ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.
Hello!
I'm trying to apply the MODSReader not to a xml-file (as in the examples provided) but rather on
requests.get-responses I've tried transforming the xml-string into a file-like object usingio.StringIO(which would be the usual way to deal with the issue in etree, I guess), but I'm getting aValueError:Could you suggest me a way to pipe the xml-string directly into the parser?
Thank you very much!