See im almost there but still wont work for me could anyone see my mistake
//XML stuff below
QFile iconfile
("/TouchTaxiMedia/iconList.xml");
{
qDebug() << "Failed to open file for write";
}
QXmlStreamWriter output2(&iconfile);
output2.setCodec("UTF-8");
output2.setAutoFormatting(true);
output2.writeStartDocument();
output2.writeStartElement("Menu");
while (sqlSelFrmView.next())
{
if(sqlSelFrmView.value(2) == "1")
{
output2.writeStartElement("Model");
output2.writeTextElement("Name", sqlSelFrmView.value(1).toString());
if (!(sqlSelFrmView.value(3) == ""))
{
output2.writeTextElement("Source", sqlSelFrmView.value(3).toString());
}
if (!(sqlSelFrmView.value(4) == ""))
{
output2.writeTextElement("Picture", sqlSelFrmView.value(4).toString());
}
if(sqlSelFrmView.value(2) == "2")
{
output2.writeStartElement("SubMenu");
output2.writeTextElement("Name", sqlSelFrmView.value(1).toString());
if (!(sqlSelFrmView.value(3) == ""))
{
output2.writeTextElement("Source", sqlSelFrmView.value(3).toString());
}
if (!(sqlSelFrmView.value(4) == ""))
{
output2.writeTextElement("Picture", sqlSelFrmView.value(4).toString());
}
output2.writeEndElement();
}
output2.writeEndElement();
}
}
output2.writeEndDocument();
//Done
//XML stuff below
QFile iconfile("/TouchTaxiMedia/iconList.xml");
if(!iconfile.open(QIODevice::WriteOnly | QIODevice::Text))
{
qDebug() << "Failed to open file for write";
}
QXmlStreamWriter output2(&iconfile);
output2.setCodec("UTF-8");
output2.setAutoFormatting(true);
output2.writeStartDocument();
output2.writeStartElement("Menu");
while (sqlSelFrmView.next())
{
if(sqlSelFrmView.value(2) == "1")
{
output2.writeStartElement("Model");
output2.writeTextElement("Name", sqlSelFrmView.value(1).toString());
if (!(sqlSelFrmView.value(3) == ""))
{
output2.writeTextElement("Source", sqlSelFrmView.value(3).toString());
}
if (!(sqlSelFrmView.value(4) == ""))
{
output2.writeTextElement("Picture", sqlSelFrmView.value(4).toString());
}
if(sqlSelFrmView.value(2) == "2")
{
output2.writeStartElement("SubMenu");
output2.writeTextElement("Name", sqlSelFrmView.value(1).toString());
if (!(sqlSelFrmView.value(3) == ""))
{
output2.writeTextElement("Source", sqlSelFrmView.value(3).toString());
}
if (!(sqlSelFrmView.value(4) == ""))
{
output2.writeTextElement("Picture", sqlSelFrmView.value(4).toString());
}
output2.writeEndElement();
}
output2.writeEndElement();
}
}
output2.writeEndDocument();
//Done
To copy to clipboard, switch view to plain text mode
its not adding the submenu in there at all
Bookmarks