Jonny D wrote:
Did you look at TiXmlDocument::Parse()? ?I don’t know where the magic is happening on Android, but if something like SDL_RWFromFile() works by itself, then you might be able to pass the char data to Parse().
Good idea
only one way to find out. Actually two ways: read the code or try it and see what happens. I’m too impatient to read code so I switched to loading using RWops to see what would happen. Here are my results:
Code:
int io::read_text(const char* source_file, char* destination)
{
// Open the file
SDL_RWops *file;
file = SDL_RWFromFile(source_file, “r”);
ASSERT(file, “Opening file using SDL_RWops”);
// Read text from file
int n_blocks = SDL_RWread(file, destination, BLOCK_SIZE, MAX_BLOCKS);
// BLOCK_SIZE = 8, MAX_BLOCKS = 1024
SDL_RWclose(file);
// Make sure the operation was successful
ASSERT(n_blocks >= 0, "Reading blocks of data from SDL_RWops");
WARN_IF(n_blocks == MAX_BLOCKS, "Reading data from SDL_RWops",
"Buffer full so may be too small for data");
// Success!
return EXIT_SUCCESS;
}
Used as follows:
Code:
// Generate world XML file name based on number
char file_name[32];
WARN_IF((sprintf(file_name, “%sworld_%d.xml”, ASSET_PATH, world_number) < 0),
“Game::load_things”, “buffer to small to create formatted string”);
/// ATTEMPT TO OPEN THE XML FILE
// Open with SDL_RWops
char file_contents[io::MAX_BLOCKS];
ASSERT(io::read_text(file_name, file_contents) == EXIT_SUCCESS,
"Reading XML World contents");
// Pass string to the TinyXML document
TiXmlDocument doc;
doc.Parse(file_contents);
ASSERT_AUX(doc.Parse(file_contents), "Opening world XML file",
doc.ErrorDesc());
Works on both Linux and Android 
Assertions are warning are used to wrap stderr or __android_log_print depending on platform. Long story short, XML can now be loaded from the assets folder. Thanks for the pointer 