Fixed bug in toXML()