When I try to parse a simple .xml file using the RapidXML framework, it throws a parse_error with this cause: "expected <". Now this is practically my first time writing XML code, so it might be a silly syntax error, in that case, bear with me :) This is my xmlParser.h:
#ifndef __XML_PARSER_H__
#define __XML_PARSER_H__
#include "rapidxml.hpp"
#include "windowUtil.h"
class XmlParser
{
public:
bool parse(char *xml)
{
try
{
doc.parse<0>(xml);
}
catch(rapidxml::parse_error &e)
{
msg_box(NULL, e.what(), "RapidXML exception!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
return false;
}
return true;
}
char* get_first_node_name()
{
return doc.first_node()->name();
}
private:
rapidxml::xml_document<> doc;
};
#endif
And this is how it is called and used:
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow)
{
XmlParser xmlParser;
WindowFramework *window = create_window(&framework, NULL, NULL, "GAME");
if(!init_window(window, true, true))
return kill(1);
if(!xmlParser.parse("./layouts/login_gui.xml"))
return kill(1);
framework.main_loop();
return kill(0);
}
login_gui.xml:
<?xml version="1.0"?>
<button>
<text>EXIT</text>
<buttonready>button.png</buttonready>
<buttonrollover>button_active.png</buttonrollover>
<buttonpressed>button_pressed.png</buttonpressed>
<buttoninactive>button_inactive.png</buttoninactive>
</button>