Refactor to_xml by XmlTree