Avoid crashing in the prettify function with comments

The prettify function didn't work properly with comments, it failed
to detect text nodes and some chunks of the xml were lost.