For example, this is frowned upon:
"100"
"10" y="54" id="Enemy001">
while this seems okay:
100 1 The first level 10 54 Enemy001
While there's nothing stopping you from reading in the second example in with TinyXml, there's no mechanism included for searching for and converting the text nodes like those that exist for attributes. So, I set out to write it.
I could have (and may still) modify TinyXml's source to include the features I desire. For now, however, I've written a seperate utility-function module.
xmlutil.h
xmlutil.cpp
xmltest.cpp
Specifically, see the functions named FirstChildText, and NextSiblingText. I tried to follow the mechanisms built into TinyXml.
Each class that I want xml access for just needs to be smart enough to read and write itself to a TiXmlElement. Here's the code that loads and writes back out the second xml example above. (From xmltest.cpp)
int main(void){ TiXmlElement xmlElement(""); if(!xml::ReadXml("test.xml", xmlElement)) { std::cout << "Couldn't read input file: test.xml\n"; return 1; } Level level; if(!level.ReadXmlElement(xmlElement)) { std::cout << "Couldn't read level\n"; return 1; } xmlElement = level.WriteXmlElement(); if(!xml::WriteXml("testoutput.xml", xmlElement)) { std::cout << "Couldn't write output file: testoutput.xml\n"; return 0; } return 0;}