Whole Function:
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);
qDebug()<<"Hello:\n"<<fieldState.toString();
return true;
}
}
insertNode(node,parent);
return true;
}
bool FieldModel::updateNode(QDomNode node,QString parent){
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);
qDebug()<<"Hello:\n"<<fieldState.toString();
return true;
}
}
insertNode(node,parent);
return true;
}
To copy to clipboard, switch view to plain text mode
Its output from line 9.
Hello:
"<FieldState>
<Blocks>
<Block id="3T">
<OccupiedState>1</OccupiedState>
<TanzimState>0</TanzimState>
<ProtectionState>0</ProtectionState>
<FailureState>0</FailureState>
</Block>
<Block id="001BT">
<OccupiedState>1</OccupiedState>
<TanzimState>0</TanzimState>
<ProtectionState>0</ProtectionState>
<FailureState>0</FailureState>
</Block>
</Blocks>
<Switches/>
<Signals/>
<LevelCrossings/>
<Routes/>
</FieldState>
"
Hello:
"<FieldState>
<Blocks>
<Block id="3T">
<OccupiedState>1</OccupiedState>
<TanzimState>0</TanzimState>
<ProtectionState>0</ProtectionState>
<FailureState>0</FailureState>
</Block>
<Block id="001BT">
<OccupiedState>1</OccupiedState>
<TanzimState>0</TanzimState>
<ProtectionState>0</ProtectionState>
<FailureState>0</FailureState>
</Block>
</Blocks>
<Switches/>
<Signals/>
<LevelCrossings/>
<Routes/>
</FieldState>
"
To copy to clipboard, switch view to plain text mode
fieldState is Class member and it is fine.
Bookmarks