test.cpp 938 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <irrXML.h>
  2. using namespace irr;
  3. using namespace io;
  4. #include <string> // we use STL strings to store data in this example
  5. int main()
  6. {
  7. IrrXMLReader* xml = createIrrXMLReader("config.xml");
  8. // strings for storing the data we want to get out of the file
  9. std::string modelFile;
  10. std::string messageText;
  11. std::string caption;
  12. // parse the file until end reached
  13. while(xml && xml->read())
  14. {
  15. switch(xml->getNodeType())
  16. {
  17. case EXN_TEXT:
  18. // in this xml file, the only text which occurs is the messageText
  19. messageText = xml->getNodeData();
  20. break;
  21. case EXN_ELEMENT:
  22. {
  23. if (!strcmp("startUpModel", xml->getNodeName()))
  24. modelFile = xml->getAttributeValue("file");
  25. else
  26. if (!strcmp("messageText", xml->getNodeName()))
  27. caption = xml->getAttributeValue("caption");
  28. }
  29. break;
  30. }
  31. }
  32. // delete the xml parser after usage
  33. delete xml;
  34. return 0;
  35. }