#include<iostream>
#include<QtGui>
#include<QtXML/QDomDocument>
#include<QtXml/QDomElement>
using namespace std;
int main(int argc, char *argv[])
{
QString fileName
= "Fichier_Dom.xml";
//Ouverture du fichier en lecture seule et en mode texte
file.
open(QFile::ReadOnly|QFile
::Text);
//Ajoute le contenu du fichier XML dans un QDomDocument et dit au QDomDocument de ne pas tenir compte dse namespaces
doc.setContent(&file, false);
//Ici, listeAppel pointe sur l'élément <CallAcountingList> de notre document
//Ici, listeAppel pointe sur un fils de <CallAcountingList>, c'est à dire <CallAcounting>
listeAppel = listeAppel.firstChildElement();
//Boucle permettant la navigation dans le fichier XML
while(!listeAppel.isNull())
{
//Si on pointe sur un élément de type <CallAcounting>
if(listeAppel.tagName() == "CallAcounting")
{
//On récupère le premier enfant de l'élément CallAcounting c'est à dire <OmniPCXOffice> ou <Checksum> ou ...
QDomElement unElement
= listeAppel.
firstChildElement();
//On parcourt tous les enfants de l'élément <CallAcounting>
while(!unElement.isNull())
{
//Si l'enfant de l'élément CallAcounting est l'élément <OmniPCXOffice>
if (unElement.tagName() == "OmniPCXOffice")
{
//On récupère le texte contenu dans la balise <OmniPCXOffice>
QString strOmniPCXOffice
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <Checksum>
else if (unElement.tagName() == "CheckSum")
{
//On récupère le texte contenu dans la balise <Checksum>
QString strChecksum
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <TicketType>
else if (unElement.tagName() == "TicketType")
{
//On récupère le texte contenu dans la balise <TicketType>
QString strTicketType
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <InitialUserType>
else if (unElement.tagName() == "InitialUserType")
{
//On récupère le texte contenu dans la balise <InitialUserType>
QString strInitialUserType
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <InitialUserID>
else if (unElement.tagName() == "InitialUserID")
{
//On récupère le texte contenu dans la balise <InitialUserID>
QString strInitialUserID
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <ChargedUserType>
else if (unElement.tagName() == "ChargedUserType")
{
//On récupère le texte contenu dans la balise <ChargedUserType>
QString strChargedUserType
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <ChargedUserID>
else if (unElement.tagName() == "ChargedUserID")
{
//On récupère le texte contenu dans la balise <ChargedUserID>
QString strChargedUserID
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <SuscriberName>
else if (unElement.tagName() == "SuscriberName")
{
//On récupère le texte contenu dans la balise <SuscriberName>
QString strSuscriberName
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <CommunicationType>
else if (unElement.tagName() == "CommunicationType")
{
//On récupère le texte contenu dans la balise <CommunicationType>
QString strCommunicationType
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <TrunkType>
else if (unElement.tagName() == "TrunkType")
{
//On récupère le texte contenu dans la balise <TrunkType>
QString strTrunkType
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <TrunkID>
else if (unElement.tagName() == "TrunkID")
{
//On récupère le texte contenu dans la balise <TrunkID>
QString strTrunkID
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <Date>
else if (unElement.tagName() == "Date")
{
//On récupère le texte contenu dans la balise <Date>
QString strDate
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <Time>
else if (unElement.tagName() == "Time")
{
//On récupère le texte contenu dans la balise <Time>
QString strTime
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <CallDuration>
else if (unElement.tagName() == "CallDuration")
{
//On récupère le texte contenu dans la balise <CallDuration>
QString strCallDuration
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <TaxesAmount>
else if (unElement.tagName() == "TaxesAmount")
{
//On récupère le texte contenu dans la balise <TaxesAmount>
QString strTaxesAmount
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <Service>
else if (unElement.tagName() == "Service")
{
//On récupère le texte contenu dans la balise <Service>
QString strService
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <DialledNumber>
else if (unElement.tagName() == "DialledNumber")
{
//On récupère le texte contenu dans la balise <DialledNumber>
QString strDialledNumber
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <DiallingMode>
else if (unElement.tagName() == "DiallingMode")
{
//On récupère le texte contenu dans la balise <DiallingMode>
QString strDiallingMode
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <RingingDuration>
else if (unElement.tagName() == "RingingDuration")
{
//On récupère le texte contenu dans la balise <RingingDuration>
QString strRingingDuration
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <Cost>
else if (unElement.tagName() == "Cost")
{
//On récupère le texte contenu dans la balise <Cost>
QString strCost
= unElement.
text();
}
//Si l'enfant de l'élément CallAcounting est l'élément <Currency>
else if (unElement.tagName() == "Currency")
{
//On récupère le texte contenu dans la balise <Currency>
QString strCurrency
= unElement.
text();
}
}
}
}
return app.exec();
}
Bookmarks