pXmlBuffer is not null terminated

pXmlBuffer is not null-terminated, so you have to pass size parameter to XmlDocument::Parse.