Bonjour,

J'utilise un fichier xml de ce type pour stocker mes informations.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
<?xml version="1.0"?>
<clients>
  <client numero="1">
    <Society_name Sociéte="****">
      <Produit Product n°="0">
        <name>***</name>
        <Key>***</Key>
        <Date>**/**/****</Date>
      </Produit>
    </Society_name>
  </client>
</clients>

J'utilise pour lire la classe suivante calqué sur l'un des tuto présent sur le site.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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;
                }
            }
         }
Mon problème se situe lorsque j'arrive sur la balise "Society_name", j'ai fais plusieurs tests et a chaque fois j'obtiens qu'il n'existe pas de child.
Du coup impossible de récupérer ce qui se trouve en dessous et je ne sais vraiment pas d’où ça peut venir.

Merci d'avance à ceux/celles qui pourront m'aider a me débloquer