toXMLString and XML parser refactoring