xml - Multiline comment with QXmlStreamWriter -


i trying comment multiline section of xml output file using qxmlstreamwriter. in loop, iterating through nested structures, , if structure noted "iscommented" need insert "< ! - -" (without spaces) continue writing xml form of output. when end of structure need insert end comment: "-->". qxmlstreamwriter::writecharacters(qstring) method won't suffice since picks out special characters such "<" , re-interprets them. have handled eradicating cases nested comments... isn't issue (the inner , outer loop guaranteed not both commented) ideas alternate solution? below example of code:

... qxmlstreamwriter writer(&myfile)  (int = 0; < bigstruct.size(); i++){    if (bigstruct.at(i)->iscommented){     //start comment sequence     //insert "<!--"   }    writer.writestartelement("bigstruct");    (int j = 0; j < smallerstruct; j++){       if (smallerstruct.at(i)->iscommented){         //start comment sequence         //insert "<!--"       }        writer.writestartelement("smallerstruct");        writer.writetextelement("stuff", "blah");       writer.writetextelement("more stuff", "blah blah blah");        writer.writeendelement();        if (smallerstruct.at(i)->iscommented){         //end comment sequence         //insert "-->"       }   }    writer.writeendelement();    if (bigstruct.at(i)->iscommented){      //endcomment sequence      //insert "-->"   } }  ...  

an example xml output may

<bigstruct>  <smallerstruct>     <stuff>blah</stuff>     <more stuff>blah blah blah</more stuff>  </smallerstruct>  <!--   <smallerstruct>     <stuff>blah</stuff>     <more stuff>blah blah blah</more stuff>  </smallerstruct>  --> </bigstruct> <!-- <bigstruct>     <smallerstruct>     <stuff>blah</stuff>     <more stuff>blah blah blah</more stuff>  </smallerstruct> </bigstruct> --> 

the writecomment() first attempt comment, however, writes single line. of course, create large string '\n' characters necessary, code necessary create block escape program flow of loops. what need slick way of having writer.startcomment() , writer.endcomment()... such can specify start , end of comment, after other xml has been written. therefore write xml using qxmlstreamwriter inside comment.

thanks time.

i don't think that's possible, looking @ qxmlstreamwriter api. use qxmlstreamwriter on temporary qbytearray, , write byte array's content comment original writer.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -