irrXML
has some helper methods to read the attribute values of specific data types from the XML. These methods basically do fast conversion between string and other numeric types such as integers and floats. Let's see how we can take advantage of those methods:
1. First, let's prepare an XML file something as follows:
<?xml version="1.0"?> <player name="Aung Sithu" level="9" xp="900" speed="0.05" />
2. Then add the following code to your
main()
function after creating the Irrlicht device:IFileSystem* fs = irrDevice->getFileSystem(); IXMLReader* xml = fs->createXMLReader("player_data.xml"); if(!xml) return 1; stringc playerName = "Player: "; int level = 0; int xp = 0; float speed = 0; cout << endl; while(xml && xml->read()) { switch(xml->getNodeType()) { case EXN_ELEMENT: { stringc nodeName= xml->getNodeName(); if (nodeName.equals_ignore_case("player")) { playerName.append(xml->getAttributeValue...