Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to create a Xml file?
Forum Updated to NodeBB v4.3 + New Features

how to create a Xml file?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 2.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on 17 Apr 2017, 12:13 last edited by
    #1

    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

    1 Reply Last reply
    0
    • B Offline
      B Offline
      beecksche
      wrote on 17 Apr 2017, 16:05 last edited by
      #2

      Hi @VInay123,
      there are several classes to read and write XML files in the Qt Framework: http://doc.qt.io/qt-5/qtxml-module.html

      The last time, i used the XML streaming classes: http://doc.qt.io/qt-5/xml-streaming.html

      Hope this helps!

      1 Reply Last reply
      1

      1/2

      17 Apr 2017, 12:13

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved