RegEx formatter replaced with XmlDocument

RegEx solution was temporary and it was failing some edge cases. With `XmlDocument`, the formatting is now more robust.