Code: Alles auswählen
// imports
#include <iostream>
#include <string>
#include <Qt/qfile.h>
#include <Qt/qstring.h>
#include <QtXml/QDomDocument>
#include <QtXml/QDomElement>
#include <QtXml/QDomNode>
int main( int argc, char* argv[] )
{
QDomDocument doc("exercise");
QFile file("myxml.xml");
if (!file.open(QIODevice::ReadOnly))
{
std::cout << "Error: file couldn't be opened !" << std::endl;
return 1;
}
if (!doc.setContent(&file))
{
file.close();
std::cout << "Error: content couldn't set !" << std::endl;
return 1;
}
QDomElement docElem = doc.documentElement();
QDomNode n = docElem.firstChild();
while(!n.isNull())
{
QDomElement e = n.toElement(); // try to convert the node to an element.
if(!e.isNull())
{
std::cout << e.tagName().toStdString() << std::endl;
}
n = n.nextSibling();
}
file.close();
system("pause");
return 0;
}Code: Alles auswählen
<?xml version="1.0"?>
<Konfiguration>
<Sektion>
<Name>MalerInfos</Name>
<Kommentar>Informationen für Maler</Kommentar>
<InfoSet>
<Info>
<Einheit>Blau</Einheit>
<Datum>01.01.2007</Datum>
<Beschreibung>Alles gruen machen</Beschreibung>
</Info>
</InfoSet>
</Sektion>
</Konfiguration>Code: Alles auswählen
`¡@ Sektion ïi@ øi@ ☼ ëFA
±BÓ ‼ `¡@ "╚ȶ ‼ Îoü|Ó0+┼Z½Ã☺ ░²⌂8®TÇ╚ ‼ ɸÅé ►Üâ|Óoü| AN@ Actx ☺ ÿ$
☻ ¶☻ £☺ [IY-░♥ 2 õ♥ Ê☻ õ☻☻â©♠ F Û☻ ÊıîÐý
♦♥ ► ♦ È ☻ ☺ ¶☺ î☼ ☺ ☻ á► ,♥ ☺ ♦ ╠‼ P► ☻ ♠ ∟$ | ☻ SsHd, ☺
☻ $ 4 C : \ W I N D O W S \ W i n S x s \ ☺ £☺ ☺ [I
F Û☻ ♦ .¡jÏ♀♀ F T♀ ♦♥ ♣ d ☺Liegt mein Problem vielleicht hier?
Code: Alles auswählen
e.tagName().toStdString()Danke und Gruß!