mardi 21 avril 2015

Read attribute names and their values from a xml file in Qt using QDomNodeList

This is my xml file.

    <Dictionary EnglishName="English (United States)" CultureName="English (United States)" Culture="en-US">
         <Value Id="ID_OK" Translation="OK" English="OK" />
         <Value Id="ID_Cancel" Translation="Cancel" English="Cancel1" />
         <Value Id="ID_DemoMode" Translation="Demo Mode" English="Demo Mode" />
        <Value Id="ID_PhoneNumberColon" Translation="Phone Number:" English="Phone Number:" />
         <Value Id="ID_FaxNumberColon" Translation="Fax Number:" English="Fax Number:" />
         <Value Id="ID_CustomerColon" Translation="Customer:" English="Customer:" />
         <Value Id="ID_CompanyColon" Translation="Company:" English="Company:" />

I am able to get values of Id,Translation and English perfectly but i am not able to get the values of "EnglishName" ,"CultureName" and "Culture". This is my codesample,

QDomDocument doc("Labguage");
QFile file("English.xml");
if (!

if (!doc.setContent(&file))

    QDomNode root = doc.namedItem("Dictionary");
    QDomNodeList nodeList = root.childNodes();
    if (nodeList.count() > 0)
       for(int iDx = 0;iDx < nodeList.count(); iDx++)
           QString EnglishName("EnglishName").nodeValue());
           QString CultureName("CultureName").nodeValue());
           QString Culture("Culture"));

QString Translation("Translation").nodeValue()); QString English("English").nodeValue()); QString Id("Id")); qDebug() << "Id: " << Id<

   I got EnglishName,CultureName and Culture as blank,where is my mistake, plz help me .


Aucun commentaire:

Enregistrer un commentaire