1

I have a Python 2.7.6 Flask application that is trying to parse a SAML XML document using the lxml library. I'm running into an issue where etree.tostring(...) returns an empty string.

etree_string = etree.tostring(etree.fromstring(b'<test1><test2></test2></test1>'))
return etree_string
# output: ''

This appears to only occur when the code is run within the Flask app, served by mod_wsgi in Apache. I say this because in the same virtualenv, if I open a python interpreter and run:

>>> etree_string = etree.tostring(etree.fromstring(b'<test1><test2></test2></test1>'))
>>> print etree_string
<test1><test2/></test1>

Anyone have an idea on what might be going on?

Nate
  • 321
  • 3
  • 6
  • use `print` instead of `return` to see text in console. `` is a HTML/XML tag so browser doesn't display it as plain text and you don't see it in browser. – furas Nov 15 '16 at 01:46
  • The output from the Werkzeug console with print is also blank. – Nate Nov 15 '16 at 02:19
  • try `print "Hello World"` maybe this code is not executed. Or maybe problem is in another part of code so show minimal working code wirh the same problem. – furas Nov 15 '16 at 02:29
  • `Print "Hello World"` works. There is mention on mod_wsgi of issues with the lxml library and I think that's what's wrong here. – Nate Nov 15 '16 at 13:13
  • *there is mention mod_wsgi documentation – Nate Nov 15 '16 at 14:18

0 Answers0