How to Append a Qxml file?? everytime the input data should be in the <main> tag .



  • if i input data more than one there makes another <main>tag and data is stored in it, which is logically wrong
    i jux want tht everytime when i enter input the input data stored in the main <main> tag. that is logically true??
    here is my code..
    @ QDomDocument document;
    QDomElement root = document.createElement("main");// creating a main tag
    document.appendChild(root);

    QDomElement book = document.createElement("book");//secondry tag
    book.setAttribute("Name ", ui->lineEdit->text());
    book.setAttribute("ID ",ui->lineEdit1->text());
    root.appendChild(book);//closing tag
    
    
     QFile file&#40;"E:/z.xml"&#41;;//the file where the input data is stored in xml
    if(!file.open(QIODevice::Append | QIODevice::Text ))
    {
        qDebug() <<"Failed to open file  ";
     
    }
    else
    {
        QTextStream stream(&file);
        stream << document.toString();
        file.close();
        qDebug() <<"finished";
    }
    

    @


  • Lifetime Qt Champion

    Please, don't "duplicate":http://qt-project.org/forums/viewthread/27883/ posts on the same subject



  • i just clarify my Question


  • Lifetime Qt Champion

    In that case, you can edit your original thread's title and content


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.