Formatting HTML result to be inserted in the DB