ich möchte eine XMl-Datei rekursiv auslesen und diese dann in einer eingenen Struktur speichern. Allerdings bekomme ich das nicht ganz hin.
Code: Alles auswählen
struct XMLNode {
QList<XMLNode> lst_child_node;
QList<QString> lst_param;
QString text;
};
class Xml {
private:
protected:
QString mxml_text;
QDomDocument mxml_document;
XMLNode *mnode_main;
QDomNode *tmp_node;
XMLNode xml_node;
XMLNode ReadNode(XMLNode *node_parent, QDomNode *node);
public:
void setXMLText(QString text);
void Create();
};
Code: Alles auswählen
void Xml::setXMLText(QString text) {
mxml_text = text;
}
void Xml::Create() {
QDomElement element_root;
QDomNode node;
mxml_document.setContent(mxml_text);
element_root = mxml_document.documentElement();
node = element_root.firstChild();
ReadNode(mnode_main, &node);
}
XMLNode Xml::ReadNode(XMLNode *node_parent, QDomNode *node) {
XMLNode xml_node;
tmp_node = new QDomNode();
*tmp_node = node->firstChild();
if(tmp_node->hasChildNodes() == true) {
node_parent->lst_child_node.push_back(ReadNode(node_parent, tmp_node));
}
else {
QDomElement element = tmp_node->toElement();
node->nextSibling();
node_parent->lst_param.push_back(lst_attirbute.item(i).nodeName());
return xml_node;
}
Hat da jemand eine Idee, wie ich das korrekt auslesen kann?