hi,everybody.
some xml docment like this:
<root><firstchild>text<firstchild></root>
i want to change the "text" to "upatetext",and i try the function "setNodeValue()",
but it doesn't work.
can anyone help me?
thanks!
hi,everybody.
some xml docment like this:
<root><firstchild>text<firstchild></root>
i want to change the "text" to "upatetext",and i try the function "setNodeValue()",
but it doesn't work.
can anyone help me?
thanks!
Qt Code:
QDomDocument xmlDocument; if ( !xmlDocument.setContent(&xmlFile, true, &errorStr, &errorLine, &errorColumn) ) { .... } rootElement.firstChildElement("firstchild").firstChild().setNodeValue("upatetext");To copy to clipboard, switch view to plain text mode
Just a comment -
Actually the text is a child node. You can identify it by node.isText() function.
Hence you need to get the firstchildelement of "firstchild" node
hi,
I have one problem.
some xml
<?xml version='1.0'?>
<configs>
<dbName>database</dbName>
<userName>user</userName>
</configs>
when xml document is like this everithing work fine:
Qt Code:
rootElement.firstChildElement("dbName").firstChild().setNodeValue("newdbname"); rootElement.firstChildElement("userName").firstChild().setNodeValue("newusername"); xml->operator <<(cfgData.toString()); file->close(); delete file; delete xml;To copy to clipboard, switch view to plain text mode
when user name or db name set empty (this is need when I dont want to know the last connection data) and save the xml data into file, the tags
<dbName>database</dbName>
<userName>user</userName>
changed to <userName/> and <dbName/>. but when I wanna save new text into this tags with setNodeValue(). after saving xml data tags still empty. when I change the tags declaration like this <dbName>...</dbName> <userName>...</userName> eveithing work fine.
WHERE IS MY MISTAKE???
thanks....
Here you have a DOM node.<dbName>database</dbName>
Here you haven't so you must create one in qt and append it. Like<dbName />
Qt Code:
dbName.appendChild(t);To copy to clipboard, switch view to plain text mode
foggy-mind (26th February 2009)
yea, your right. thanks.
Bookmarks