qt - How do I create QDomNodes manually? -


i'm working on unit test meta data loader, takes qdomnode , extracts information std::map. have create qdomnode holding information want extract. node taken out of xml-file, why thought might this:

qdomnode metanode() {   qdomdocument document;    qbytearray metaarray(     "<item name=\"author\">testmanager</item>"     "<item name=\"campaign\">testcampaign</item>"     "<item name=\"comment\">testcomment</item>"     "<item name=\"date\">25.04.2013</item>"     "<item name=\"description\">testdescription</item>"     "<item name=\"projnum\">1</item>"     "<item name=\"title\">test</item>");    document.setcontent(metaarray);   qdomnode meta = document;    return meta; } 

but doesn't seem work. when call meta.childnodes() i'd expect list of 7 items, first one, holding name "author" value "testmanager";

so after mat pointed pointed out missing 'container' node, tried , made work.
this working code, enables me use node read xml-file (but without file-system dependencies):

qdomnode metanode() {   qdomdocument document;    qbytearray metaarray(   "<metadata>"     "<item name=\"author\">testmanager</item>"     "<item name=\"campaign\">testcampaign</item>"     "<item name=\"comment\">testcomment</item>"     "<item name=\"date\">25.04.2013</item>"     "<item name=\"description\">testdescription</item>"     "<item name=\"projnum\">1</item>"     "<item name=\"title\">test</item>"   "</metadata>");    document.setcontent(metaarray);   qdomnode meta = document;    return meta; } 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -