Hope this can help someone who meets the same problem.
if you kmlstring="
<?xml version='1.0' encoding='UTF-8'?><kml xmlns='http://
www.opengis.net/kml/2.2' xmlns:gx='
http://www.google.com/kml/ext/
2.2'><Document></Document></kml>
"
Make sure there is no empty-space contains inside the kmlstring.
if you use Javascript, please use the following function:
kmlstring=kmlstring.trim();