Qxml update node value

From QT Wikipedia

Jump to: navigation, search

CPP example of editing node value

XML file:

 
<?xml version='1.0' encoding='utf-8'?>
<wallsettings>
 <url>animeonly.org/walls/</url>
 <changefrequency>Naujas daznis</changefrequency>
 <currentalbumindex>5</currentalbumindex>
</wallsettings>
 

CPP code:

 
QDomElement root = doc->firstChildElement("wallsettings");
QDomElement oldTitleElement = root.firstChildElement(elementName);// let say URL
QDomElement newTitleElement = doc->createElement(elementName); //Create overide element
QDomText newTitleText = doc->createTextNode(attributeValue);   //Create text node with new value
newTitleElement.appendChild(newTitleText);                     //Append text node
root.replaceChild(newTitleElement, oldTitleElement);           //Replace with new node value
 

Personal tools
Toolbox