I have an xml file like this:
Qt Code:
  1. <start_header>
  2. "text1"
  3. "text2"
  4. </start_header>
  5. <option>
  6. "text3"
  7. "text4"
  8. </option>
  9.  
  10. ...and so on
To copy to clipboard, switch view to plain text mode 

I'd like to extract just the Textelement between each pair of tag and write it
in a file.txt

File.txt content:
"text1"
"text2"
"text3"
"text4"

I use the special class QXmlStreamReader and i try to obtain this behaviour with this code:
Qt Code:
  1. QFile *file=new QFile("source.xml")
  2. QFile *f=new QFile("output.txt");
  3. if(!f->open(QIODevice::ReadWrite))
  4. std::cout<<"f problem"<<std::endl;
  5. if(!file->open(QIODevice::ReadWrite))
  6. std::cout<<"f problem"<<std::endl;
  7.  
  8. QTextStream out(f);
  9. QXmlStreamReader xml(file);
  10.  
  11. while(!xml.atEnd()){
  12. if (xml.readNext() == QXmlStreamReader::StartElement)
  13. out<<xml.readElementText()<<"\n";
  14. }
  15. f->close();
  16. file->close();
To copy to clipboard, switch view to plain text mode 

The output file wasn't writed......
What's wrong with this code?
Is there an other method, to obtain the behaviuor I looked for?