Ich möchte XML Datei in UE4 einlesen . Ich habe es versucht mit rein C++ ( also ohne UE4) und es hat geklappt. Aber wie kann ich das Code in UE4 verwenden bzw umschreiben. Wie kann ich auch "Output of Code" als Array speichern
Kann jemand bitte weiterhelfen.
das Code:
C
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include "rapidxml-1.13/rapidxml.hpp"
using namespace rapidxml;
using namespace std;
int mul(int x, int y)
{
return x * y;
}
void XMLRead(string file)
{
xml_document<> doc;
xml_node<> * root_node;
// Read the xml file into a vector
ifstream theFile(file);
vector<char> buffer((istreambuf_iterator<char>(theFile)), istreambuf_iterator<char>());
buffer.push_back('\0');
// Parse the buffer using the xml file parsing library into doc
doc.parse<0>(&buffer[0]);
// Find our root node
root_node = doc.first_node("Points");
// Iterate over the elements
for (xml_node<> * Point_node = root_node->first_node("Point"); Point_node; Point_node = Point_node->next_sibling())
{
// Interate over the unterlement
for (xml_node<> * node = Point_node->first_node(); node; node = node->next_sibling())
{
printf("%s ", node->value());
}
cout << endl;
}
}
int main()
{
// cout << mul(3, 4);
XMLRead("coordinate.xml");
cin.get();
return 0;
}
und XML Datei:
<?xml version="1.0" encoding="UTF-8"?>
<Points>
<Point>
<X>0</X>
<Y>-380</Y>
<Z>0</Z>
<rX>0</rX>
<rY>0</rY>
<rZ>0</rZ>
<sX>1</sX>
<sY>1</sY>
<sZ>1</sZ>
</Point>
<Point>
<X>0</X>
<Y>900</Y>
<Z>0</Z>
<rX>0</rX>
<rY>0</rY>
<rZ>0</rZ>
<sX>1</sX>
<sY>1</sY>
<sZ>1</sZ>
</Point>
<Point>
<X>1350</X>
<Y>-380</Y>
<Z>0</Z>
<rX>0</rX>
<rY>0</rY>
<rZ>0</rZ>
<sX>1</sX>
<sY>1</sY>
<sZ>1</sZ>
</Point>
<Point>
<X>2700</X>
<Y>-2000</Y>
<Z>0</Z>
<rX>0</rX>
<rY>0</rY>
<rZ>0</rZ>
<sX>1</sX>
<sY>1</sY>
<sZ>1</sZ>
</Point>
<Point>
<X>0</X>
<Y>-1800</Y>
<Z>0</Z>
<rX>0</rX>
<rY>0</rY>
<rZ>0</rZ>
<sX>1</sX>
<sY>1</sY>
<sZ>1</sZ>
</Point>
<Point>
<X>2700</X>
<Y>-380</Y>
<Z>0</Z>
<rX>0</rX>
<rY>0</rY>
<rZ>0</rZ>
<sX>1</sX>
<sY>1</sY>
<sZ>1</sZ>
</Point>
<Point>
<X>1500</X>
<Y>-2600</Y>
<Z>0</Z>
<rX>0</rX>
<rY>0</rY>
<rZ>0</rZ>
<sX>1</sX>
<sY>1</sY>
<sZ>1</sZ>
</Point>
<Point>
<X>2700</X>
<Y>900</Y>
<Z>0</Z>
<rX>0</rX>
<rY>0</rY>
<rZ>0</rZ>
<sX>1</sX>
<sY>1</sY>
<sZ>1</sZ>
</Point>
<Point>
<X>1500</X>
<Y>1800</Y>
<Z>0</Z>
<rX>0</rX>
<rY>0</rY>
<rZ>0</rZ>
<sX>1</sX>
<sY>1</sY>
<sZ>1</sZ>
</Point>
<Point>
<X>1500</X>
<Y>-2600</Y>
<Z>0</Z>
<rX>0</rX>
<rY>0</rY>
<rZ>0</rZ>
<sX>1</sX>
<sY>1</sY>
<sZ>1</sZ>
</Point>
</Points>
Alles anzeigen