fix some bugs in XmlParser (see #3381)