added toXML() and fromXML() methods