this will show a very simple xml parser just to get you to look at syntax. this is from tiled.
Does not go into graphics it just shows how to get csv format from tiled.
xml part
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="20" height="15" tilewidth="50" tileheight="50">
<properties>
<property name="background_color" value="#00C0FF"/>
</properties>
<tileset firstgid="1" name="tileset" tilewidth="50" tileheight="50">
<image source="../../../../../Desktop/New Folder (3)/result/Texture 0.png" width="250" height="250"/>
</tileset>
<layer name="Tile Layer 1" width="20" height="15">
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
22,22,22,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,22,22,22,22,22,22,22,22,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,
22,22,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,
22,0,22,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,10,
0,0,0,22,22,22,22,22,22,22,22,22,10,10,10,10,10,10,10,10,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data>
</layer>
</map>
c++ part
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include "rapidxml.h"
using namespace rapidxml;
using namespace std;
void main()
{
ifstream inFile("map.tmx");
string xmlContents;
string line;
string line2;
while(getline(inFile, line))
xmlContents += line;
vector<char> xmlData = vector<char>(xmlContents.begin(), xmlContents.end());
xmlData.push_back('\0');
xml_document<> doc;
doc.parse<parse_no_data_nodes>(&xmlData[0]);
xml_node<> *behaviourtreeNodes = doc.first_node("map");
//Get the root node
while(behaviourtreeNodes)
{
xml_node<>* layer= behaviourtreeNodes->first_node("layer");
while(layer)
{
cout<<"n";
cout<<layer->first_attribute("width")->value();
xml_node<>* data = layer->first_node("data");
while(data)
{
cout<<data->value();
data=data->next_sibling();
}
layer = layer->next_sibling();
}
behaviourtreeNodes = behaviourtreeNodes->next_sibling();
}
system("pause");
}
Developer of Space Chips, pianobasic, and zipzapzoom apps.
Veterian for the military.