how to create a Xml file?
-
I have a Qt widget and in this a line edit is present. Now i have saved a xml file name "file1.xml" in a particular location. The xml file is as below: file1.xml
<?xml version="1.0" encoding="UTF-8"?>
<Objects>
<property1 = color, property2 = %1 />
</Objects>
now in my widget i have a function named readfile which takes the above file path name, an Qstring argument and output directory. Now this function opens the above file and stores everything in QbyteArray object and in this array it replaces %1 witht eh string argument and saves in a given directory as follows, here argument was blue.<?xml version="1.0" encoding="UTF-8"?>
<Objects>
<property1 = color, property2 = blue />
</Objects>
But now i want to create the property tag dynamically, i.e. if user gives an input in a line edit with "2" then it should take the above "file1.xml" and create in the given directory as follows:<?xml version="1.0" encoding="UTF-8"?>
<Objects>
<property1 = color, property2 = blue />
<property1 = color, property2 = red />
</Objects>
How do i do it? and in worst case i could modify the static "file1.xml". The input can be a max of 3. Thank You -
Hi @VInay123,
there are several classes to read and write XML files in the Qt Framework: http://doc.qt.io/qt-5/qtxml-module.htmlThe last time, i used the XML streaming classes: http://doc.qt.io/qt-5/xml-streaming.html
Hope this helps!