Here my source code:
QDomElement rootOfTag
=fieldState.
firstChild().
firstChildElement(parent
);
QDomNodeList sameTags
=rootOfTag.
elementsByTagName(node.
firstChild().
toElement().
tagName());
for(uint i=0;i<sameTags.length();i++)
{
QDomNode nodeToReplace
=sameTags.
item(i
);
if(nodeToReplace.toElement().attribute("id")==node.firstChild().toElement().attribute("id"))
{
rootOfTag.removeChild(nodeToReplace);
return true;
}
}
QDomElement rootOfTag=fieldState.firstChild().firstChildElement(parent);
QDomNodeList sameTags=rootOfTag.elementsByTagName(node.firstChild().toElement().tagName());
for(uint i=0;i<sameTags.length();i++)
{
QDomNode nodeToReplace=sameTags.item(i);
if(nodeToReplace.toElement().attribute("id")==node.firstChild().toElement().attribute("id"))
{
rootOfTag.removeChild(nodeToReplace);
return true;
}
}
To copy to clipboard, switch view to plain text mode
Although it enters into if part, it can't remove "nodeToReplace" . What can be my problem?
Edit: nodeToReplace.nodeType() returns QDomNode::ElementNode, can problem related with that?
Bookmarks