First decodeXML version, and correct some bugs