The included Montgomery.gdb does not include a feature class named centroids. Are you using Final or Beta 3?The following code exports the XML from the Blocks feature class. It does include the spatial reference.#include <string>
#include <iostream>
#include <fstream>
#include <FileGDBAPI.h>
using namespace std;
using namespace FileGDBAPI;
int main()
{
// Open the geodatabase.
fgdbError hr;
wstring errorText;
Geodatabase geodatabase;
if ((hr = OpenGeodatabase(L"C:/FileGDB_API_Issues/Montgomery.gdb", geodatabase)) != S_OK)
{
wcout << "An error occurred while opening the geodatabase." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return -1;
}
Table table;
if ((hr = geodatabase.OpenTable(L"\\Landbase\\Blocks", table)) != S_OK)
{
wcout << "An error occurred while opening the table." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return -1;
}
string tableDef;
if ((hr = table.GetDefinition(tableDef)) != S_OK)
{
wcout << "An error occurred while opening the table." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return -1;
}
ofstream myfile;
myfile.open("../Blocks.xml", ios::out);
myfile << tableDef;
tableDef.clear();
myfile.close();
// Close the table
if ((hr = geodatabase.CloseTable(table)) != S_OK)
{
wcout << "An error occurred while closing Cities." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return -1;
}
// Close the geodatabase
if ((hr = CloseGeodatabase(geodatabase)) != S_OK)
{
wcout << "An error occurred while closing the geodatabase." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return -1;
}
return 0;
}