Replaced old code with replace_xml_element() method call