@Paul-Colby i am opening xml file as you mentioned first time when i pressed save button it will show <?xml version='1.0'?> <xml> <tag1> </tag1> // two spaces from line edit </xml> second time when i presses save button it will show <?xml version='1.0'?> <xml> <tag1/> // some data in lineedit </xml> third time when i presses save button it will show <?xml version='1.0'?> <xml> <tag1/> // some data in lineedit </xml> i am using Qt 4.8.7, i am opening xml file , see the result