Format XML file
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" ?>
<StdThickness> T </StdThickness>
<Thickness_num> 0.032 </Thickness_num>
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 .
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
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 .
What do you mean by "format it"? Are you talking about displaying it on screen? Or changing it on disk?
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 .
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.