improve buildXML()

removed foreach, replaced with array_walk() and lamba function
replaced str_replace() with strtr()