c++ - QTDom - recursively add child to specific elements -
i have few xml files, , of it's nodes contains "reference" each other. want add content of xml child nodes, contains references
void gameobject::expandnode(qdomelement& expnode) { if ((expnode.tagname() == "instance" && expnode.attribute("type") == "library") || (expnode.tagname() == "library" && expnode.hasattribute("file"))) { qstring filename; if (expnode.tagname() == "instance" ) filename = findlib(expnode.attribute("definition")).attribute("file"); else filename = expnode.attribute("file"); qfile nestedfile(filename); qdomdocument nestedlib; nestedlib.setcontent(&nestedfile); qdomelement nestednode = libdoc->createelement("nestedlibrary"); nestednode.setattribute("path", filename); nestednode.appendchild(nestedlib); expnode.appendchild(nestednode); } qdomnode childnode = expnode.firstchild(); while (!childnode.isnull()) { if (childnode.iselement()) expandnode(childnode.toelement()); childnode = childnode.nextsibling(); } }
but got no matching function call 'gameobject::expandnode(qdomelement)' expandnode(childnode.toelement());
how can right? ^
it wrong decision - call expandnode, using temporary object. solution is
qdomnode childnode = expnode.firstchild(); while (!childnode.isnull()) { if (childnode.iselement()) { qdomelement childelem = childnode.toelement(); expandnode(childelem); } childnode = childnode.nextsibling(); }
Comments
Post a Comment