Fixed a bug in writing of XML nodes