I have the following xml file:
<?xml version="1.0" ?>
<Hello>World</Hello>
Which is located in the very same directory as all my other files.
And I use this source file method to parse it:
void Character::assign_xml(const char * filename) //Assign xml takes the name of the xml file as a string, and uses it to parse the file's nodes.
{
TiXmlDocument * doc = new TiXmlDocument(filename);
bool loadOkay = doc->LoadFile(filename);
if (loadOkay)
{
printf("\n%s\n", filename);
}
else
{
printf("%s does not work.", filename);
}
delete doc;
}
Yet, when I pass the string to it, my loadOkay variable amounts to false. Why is this?
My output produces the following:
Starting /home/holland/code/qt/chronos-build-desktop/chronos...
id01.xml does not work.Failed to open file/home/holland/code/qt/chronos-build-desktop/chronos exited with code 0
Where as an strace provides:
futex(0x84579c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
open("id01.xml", O_RDONLY) = -1 ENOENT (No such file or directory)
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb773e000
write(1, "id01.xml does not work.Failed to"..., 42id01.xml does not work.Failed to open file) = 42
You shouldn't pass the filename both to the document constructor and to LoadFile()
. Try omitting it from the latter, as per the examples on TinyXML's site.
If it still doesn't work, print out doc->ErrorDesc()
(and possibly ErrorRow and ErrorCol).
And read the documentation: http://www.grinninglizard.com/tinyxmldocs/classTiXmlDocument.html