Hi,
First time using QT and XML. Here is my simple XML file.
<?xml version="1.0"?>
<Node nodetype="atomic"
header="atomic.h">
<Input name="inNumber" type="color" value="0.2,0.3,0.5"/>
<Output name="outNumber" type="float" value="0.5"/>
</Node>
<?xml version="1.0"?>
<Node nodetype="atomic"
header="atomic.h">
<Input name="inNumber" type="color" value="0.2,0.3,0.5"/>
<Output name="outNumber" type="float" value="0.5"/>
</Node>
To copy to clipboard, switch view to plain text mode
and here is the QT code:
QFile file("atomic.xml");
return 0;
if (!doc.setContent(&file)) {
file.close();
return 0;
}
file.close();
while(!n.isNull()) {
if(n.isElement()) {
qDebug() << name;
if(name == "Node") {
QString nodeType
= e.
attribute("nodetype",
"");
QString header
= e.
attribute("header",
"");
qDebug() << nodeType << header;
} else if(name == "Input") {
QString name1
= e.
attribute("name",
"");
QString type1
= e.
attribute("type",
"");
QString value1
= e.
attribute("value",
"");
qDebug() << name1 << type1 << value1;
}
}
n = n.nextSibling();
}
QFile file("atomic.xml");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return 0;
QDomDocument doc;
if (!doc.setContent(&file)) {
file.close();
return 0;
}
file.close();
QDomNode n = doc.firstChild();
while(!n.isNull()) {
if(n.isElement()) {
QDomElement e = n.toElement();
QString name = e.tagName();
qDebug() << name;
if(name == "Node") {
QString nodeType = e.attribute("nodetype","");
QString header = e.attribute("header","");
qDebug() << nodeType << header;
} else if(name == "Input") {
QString name1 = e.attribute("name","");
QString type1 = e.attribute("type","");
QString value1 = e.attribute("value","");
qDebug() << name1 << type1 << value1;
}
}
n = n.nextSibling();
}
To copy to clipboard, switch view to plain text mode
Problem 1
The code is not entering in condition:
else if(name == "Input") {
else if(name == "Input") {
To copy to clipboard, switch view to plain text mode
Cheers
Prashant
Bookmarks