Hi,

I am trying to read configuration with QDomDocument. I managed to get writting configuration to work. When reading I get the settings but don't get any phone numbers.

This is an example of what I might read (there can be between 0 and 999 phone numbers):

Qt Code:
  1. <!--Main Settings-->
  2. <settings AfterHourOffset="100" NumPerButton="1" MaxNumToDial="1" />
  3. <!--Phone Book List-->
  4. <phone location="0" value="911" />
  5. <phone location="1" value="33782134" />
  6. <phone location="2" value="000" />
  7. <phone location="3" value="ABCD" />
  8. <phone location="8" value="13005696" />
  9. <phone location="990" value="38441104" />
  10. <phone location="999" value="131333" />
To copy to clipboard, switch view to plain text mode 

Here's my current attempt:

Qt Code:
  1. QFile file("fred.xml");
  2.  
  3. if(file.open(QIODevice::ReadOnly | QIODevice::Text)) {
  4.  
  5.  
  6. d.setContent(&file);
  7.  
  8. QDomNode n = d.firstChild();
  9.  
  10. ClearPhoneNumbers(); // Clear phone table.
  11.  
  12. while(!n.isNull()) {
  13.  
  14. if(n.isElement()) {
  15.  
  16. QDomElement e = n.toElement();
  17. QString name = e.tagName();
  18.  
  19. if(name == "settings") {
  20.  
  21. ui->Edit1->setText(e.attribute("AfterHourOffset",""));
  22. ui->Edit2->setText(e.attribute("MaxNumToDial",""));
  23. ui->Edit3->setText(e.attribute("NumPerButton",""));
  24.  
  25. } else if(name == "phone") {
  26.  
  27. QString location = e.attribute("location","");
  28. QString value = e.attribute("value","");
  29.  
  30. AddPhoneBook(location, value); // Add to phone table.
  31. }
  32. }
  33. n = n.nextSibling();
  34. }
  35. file.close();
  36. }
To copy to clipboard, switch view to plain text mode 

See whats wrong?

Thanks
Brendan