I am using a web2py application, in that I have a requirement like, In my first page I have to create an web2py DIV() tag, display it and store that value in database. And in the second page I have to get this database value and add this inside a TABLE() function.
It is not throwing error. But In the second page view the division content is display as XML, instead of display as HTML.
So inside my HTML table I am getting the value as <div style="float:right">content</div>
I think the DIV() is stored in the database as xml(). How can I convert this xml() back to DIV().
The database is storing the original HTML. However, any text written to a web2py view is automatically escaped, so the HTML code displays literally rather than being rendered as HTML. To avoid that, as you have pointed out, you can simply wrap the HTML in the
XML()helper.Be careful, though — you should not do this with input entered by users. A malicious user could enter Javascript code, which could create a security vulnerability for other users viewing that content (this is why web2py automatically escapes everything in the first place). To be safer, you could also do
XML(..., sanitize=True).