I have an xml-file which looks like this:
<ItemList>
<Item>
<Name>Spear</Name>
<Description>This is an ordinary spear</Description>
<Value>100</Value>
<Magical>0</Magical>
</Item>
<Item>
<Name>Mace</Name>
<Description>This is an ordinary mace</Description>
<Value>75</Value>
<Magical>0</Magical>
</Item>
</ItemList>
I'm trying to parse it using TinyXML into a ItemData struct.
struct ItemData
{
std::string name;
std::string description;
int value;
bool magical;
};
This is with TIXML_USE_STL defined. The problem is that I don't understand how to get the text from inside <Name></Name> for example. This code just prints 0000000
TiXmlDocument doc( "ItemList.xml" );
TiXmlHandle handle( &doc );
TiXmlText* s = handle.FirstChild( "ItemList" ).FirstChild( "Item" ).FirstChildElement( "Name" ).Text();
std::cout << s << std::endl;
Another question too, how do I read each entry into a ItemData struct and store all of them in a vector?