TinyXML++

Started by
2 comments, last by Mike Morrison 13 years, 3 months ago
[font="arial, sans-serif"]I have one .xml file and I'm opening it with TinyXML + +, but do not know how to read thetwo values that have (resolution and fullscreen)
[font="arial, sans-serif"]
[font="arial, sans-serif"]my code:
[font="arial, sans-serif"] // Load the xml file
TiXmlDocument XMLdoc("Data\\Settings.xml");
bool loadOkay = XMLdoc.LoadFile();
if (loadOkay)
{
::MessageBox(NULL, "Settings.xml loaded!", "OK", MB_OK);
}
else
{
::MessageBox(NULL, "Settings.xml not loaded!", "ERROR", MB_OK);
}


[font="arial, sans-serif"]
[font="arial, sans-serif"].xml
[font="arial, sans-serif"]
<!DOCTYPE Settings>
<Settings>
<layer Resolution="1024x768"/>
<layer Fullscreen="no"/>
</Settings>
http://mateusvitali.wordpress.com/
Advertisement
anyone?
http://mateusvitali.wordpress.com/

anyone?


i think google knows something about it TINYXML wiki
Attach a TiXmlHandle to the document:
TiXmlHandle docHandle(&XMLdoc);

Then you can ask for the Settings element, which would be the root.
And from that element you can get the other two.

Btw, I think it would be better if avoid having two elements with the same name but different sets of attributes.
That way your parser won't have to try all combinations when parsing such an item.
You could use this approach for example:
<setting name="resolution" value="800x600"/>
<setting name="fullscreen" value="off"/>


Regards
Mike

This topic is closed to new replies.

Advertisement