I had the exact same problem. The exported XML-File is imported to MS Project 2010 correctly if I call the following function before exporting:
projectFile.getTasks().synchronizeTaskIDToHierarchy();
(The answer from Jon Ilnes was a good hint but not 100% correct, because the getTasks()
was missing in the middle.)