1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| UnSerializer::UnSerializer()
{
QFile file("clients_liste.xml");
if (!file.open(QIODevice::ReadOnly))
return ;
if (!doc.setContent(&file))
{
file.close();
return ;
}
file.close();
}
UnSerializer::~UnSerializer()
{}
void UnSerializer::lire()
{
int i=0;
QDomNodeList tab;
QDomElement _client;
QDomNode n;
QDomNode n1;
QDomNode n2;
QDomElement racine = doc.documentElement(); // renvoie la balise racine
for(QDomNode n = racine.firstChild(); !n.isNull(); n = n.nextSibling())
{
_client = n.toElement();
if (_client.tagName() == "client")
{
std::cout << "client numero :" << _client.attribute("numero").toStdString() << std::endl;
QDomElement _society = _client.firstChildElement("Society_name");
for (; !_society.isNull(); _society = _society.nextSiblingElement("Society_name"))
{
std::cout << "Société :" << _society.attribute("Sociéte").toStdString() << std::endl;
std::cout << _society.hasChildNodes() << std::endl;
tab = _society.childNodes();
if(tab.isEmpty())
std::cout << "null" << std::endl;
// QDomElement _Produit = _society.firstChildElement("Produit");
// if (_Produit.isNull())
// std::cout << "test" << std::endl;
// for(; !_Produit.isNull(); _Produit=_Produit.nextSiblingElement("Produit"))
// std::cout << _Produit.attribute("Product n°").toStdString() << std::endl;
}
}
} |
Partager