hello:

I have been having problems setting the value of a QDOMElement instance. The following is my code:


Qt Code:
  1. int main (int argc, char * argv[])
  2. {
  3. QApplication app(argc,argv);
  4.  
  5. QDomDocument d("bookml");
  6. QDomElement root = d.createElement("rootelement");
  7. d.appendChild(root);
  8. QDomElement e = d.createElement("BookList");
  9. root.appendChild(e);
  10.  
  11. QDomElement e0 = d.createElement("BookName");
  12. e.appendChild(e0);
  13. e0.setNodeValue("The Da Vinci Code");
  14. QDomElement e1 = d.createElement("BookPrice");
  15. e1.setNodeValue("45.50");
  16. e.appendChild(e1);
  17.  
  18.  
  19. QFile mFile("test.xml");
  20. if ( !mFile.open(QIODevice::WriteOnly ) )
  21. {
  22. std::cout << "Failed creating file" << std::endl;
  23. return -1;
  24. }
  25. QTextStream s(&mFile);
  26. s << d.toString();
  27. mFile.close();
  28. return app.exec();
  29. }
To copy to clipboard, switch view to plain text mode 

And as output in Internet Explorer I get:


Qt Code:
  1. <!DOCTYPE bookml (View Source for full doctype...)>
  2. - <rootelement>
  3. - <BookList>
  4. <BookName />
  5. <BookPrice />
  6. </BookList>
  7. </rootelement>
To copy to clipboard, switch view to plain text mode 

One can notice that the tags are formed but the values of the BookName and BookPrice which I am supplying using the setNodeValue method are not being seen here.

Any help would be appreciated.