![Wink :wink:](./images/smilies/icon_wink.gif)
becouse i tried the meshviewer tutorial but that only works if you have only one text to read but i need to read a lot more then that.
a different tutorial would also be nice
thanks in advance
Code: Select all
<?xml version="1.0"?>
<config>
<!-- This is a config file for the mesh viewer -->
<model file="dwarf.dea" />
<messageText caption="Irrlicht Engine Mesh Viewer">
Welcome to the Mesh Viewer of the "Irrlicht Engine".
</messageText>
</config>
Code: Select all
#include <irrXML.h>
using namespace irr; // irrXML is located in the namespace irr::io
using namespace io;
#include <string> // we use STL strings to store data in this example
void main()
{
// create the reader using one of the factory functions
IrrXMLReader* xml = createIrrXMLReader("config.xml");
// strings for storing the data we want to get out of the file
std::string modelFile;
std::string messageText;
std::string caption;
// parse the file until end reached
while(xml && xml->read())
{
switch(xml->getNodeType())
{
case EXN_TEXT:
// in this xml file, the only text which occurs is the messageText
messageText = xml->getNodeData();
break;
case EXN_ELEMENT:
{
if (!strcmp("model", xml->getNodeName()))
modelFile = xml->getAttributeValue("file");
else
if (!strcmp("messageText", xml->getNodeName()))
caption = xml->getAttributeValue("caption");
}
break;
}
}
// delete the xml parser after usage
delete xml;
}
Code: Select all
if (!strcmp("nodename1", xml->getNodeName()))
{
trackingNode = 1;
}
else
{
trackingNode = 2;
}
Code: Select all
switch(trackingNode)
{
case 1:
//do something with text
break;
case 2:
//do something else with text
break;
}
and don't get me wrong becouse without your help i wouldn't have figured this outIXMLReader* xml = device->getFileSystem()->createXMLReader("config.xml");
while(xml && xml->read())
{
switch(xml->getNodeType())
{
case EXN_ELEMENT:
trackingNode = xml->getNodeName();
break;
case EXN_TEXT:
if (trackingNode == "udriver")//udriver is the xml element
{
driv = xml->getNodeData();
}
break;
}
}
if (xml)
xml->drop();