[Qt-interest] how to quickly modify the value of attribute

yanqzhi at gmail.com yanqzhi at gmail.com
Wed Oct 20 04:44:54 CEST 2010


This method maybe help you.

Open a xml with read and write, 

setAttribute(const QString &tagName, const QString &attributeName, const QString &value)
{
 QDomNodeList nodeList = mDoc.elementsByTagName(tagName);
 if (nodeList.length() < 1)
 {
  return false;
 }
//I only change the first elment's attribute 
QDomElement domElement = nodeList.at(0).toElement();
 domElement.setAttribute(attributeName, value);
}



Sincerely yours, 

yanqzhi at gmail.com 
2010-10-20 

======= 2010-10-20 10:28, your message: [Qt-interest] how to quickly modify the value of attribute======= 


Hi All:
         I don’t whether there is a good method to find an attribute and modify its value. (Normal method: open a xml with read only
And open new xml with write only, scan former xml one by one and write to new xml one by one, if find the attribute, write new value of attribute to new xml.)
I don’t want use this method. Anybody has other method?
Anybody has experience?
Thanks
彭亮 Ken


= = = = = = = = = = = = = = = = = = = = 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101019/01d972a7/attachment.html 


More information about the Qt-interest-old mailing list