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. Format XML file
QtWS25 Last Chance

Format XML file

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 3.1k 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.
  • B Offline
    B Offline
    BibekKumar
    wrote on 19 Dec 2012, 06:34 last edited by
    #1

    I have a xml file where outputs are not getting formatted . That means all the outputs are in a single line but i want to break it tag by tag .

    For e.g. -

    @ <?xml version="1.0" encoding="UTF-8" standalone="no" ?><Analyser> <JointDetails> <Details><StdThickness> T </StdThickness><Thickness_num> 0.032 </Thickness_num></Details> </JointDetails></Analyser>@

    But i want to do it like this ::

    @ <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
    <Analyser>
    <JointDetails>
    <Details>
    <StdThickness> T </StdThickness>
    <Thickness_num> 0.032 </Thickness_num>
    </Details>
    </JointDetails>
    </Analyser>
    @
    Please dont suggest to do it while writting the XML file because this xml file is already there but now i have to format it as mentioned above .

    Thanks in advance .

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hpollak
      wrote on 19 Dec 2012, 07:01 last edited by
      #2

      Your Document is in DOM-Format.

      See the example in Documentation ("qdomdocument":http://qt-project.org/doc/qt-5.0/qtxml/qdomdocument.html) there is a simple prettyprinter

      1 Reply Last reply
      0
      • B Offline
        B Offline
        BibekKumar
        wrote on 20 Dec 2012, 05:59 last edited by
        #3

        I don't want to write a XML file . The XML file is already there , just i need to format it since its in a single line . I want to break it into tag by tag .

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mlong
          wrote on 20 Dec 2012, 17:01 last edited by
          #4

          What do you mean by "format it"? Are you talking about displaying it on screen? Or changing it on disk?

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            BibekKumar
            wrote on 21 Dec 2012, 05:38 last edited by
            #5

            I have a file where all the XML tags are stored in a single line . But i want to break it tag by tag as shown above , so that it will be readable . Please don't suggest for writing it again using QXmlStreamWriter / QDomDocument .Please suggest some other concept .

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mlong
              wrote on 21 Dec 2012, 06:18 last edited by
              #6

              You cannot change a file on disk, XML or otherwise, without writing to it. Would you care to explain why you are so vehemently against rewriting it using QXmlStreamWriter or QDomDocument, as those are your best bets for doing what you would like to do?

              Your demands for another concept are very confusing (as well as worded somewhat rudely.) Even if you didn't want to use the XML classes to parse and rewrite your file, you would still have to read it and process it and write it out somehow.

              It sounds as if you're wanting a magic method to shove some white space into arbitrary parts of in the middle of a preexisting file. That is simply impossible to do without rewriting your file some way.

              Software Engineer
              My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

              1 Reply Last reply
              0

              1/6

              19 Dec 2012, 06:34

              • Login

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