Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Choosing XML element vs attribute
viniltc last edited by viniltc
I'm hoping to get feedback from Qt Xml experts.
I am aiming to reconstruct a .txt file of the following format from XML file.
P P0 "Phase zero" 0ms NONE 2000ms STOP STOP STOP O CH1 0mA 0ms 0ms 600000ns 180us RATE O CH2 0mA 0ms 0ms 600000ns 180us RATE O CH3 0mA 0ms 0ms 600000ns 180us RATE P P1 "Phase one" 0ms NONE 2000ms STOP STOP STOP O CH1 0mA 0ms 0ms 600000ns 180us RATE O CH2 0mA 0ms 0ms 600000ns 180us RATE O CH3 0mA 0ms 0ms 600000ns 180us RATE
Each node has a
O). The node
parametersare presented as a list of space separated variables. The parameter values are collected using widgets like
I'm a bit confused to determine the structure of the XML file recreates the above mentioned txt file. Should I use XML
attributeor combination of both to easily reconstruct?
I really appreciate if someone can show me an example.
Thanks in advance
Your description is a bit unclear. Do you have XML data that you want to convert ? Or are you reading that txt file and want to translate it to XML ?
JonB last edited by
For an XML representation like this (where the elements do not break down into sub-elements themselves), it truly does not matter whether you choose an element, attribute or mixture schema, it's up to you, both are valid and will be seen in various implementations.
If I have a lot of elements I tend to prefer XML elements over attributes for sure, because they are easier to see/manage. If I regard something as a "property" I might go attribute.
Here you seem to have 7 elements to associate with each
O. My inclination would be to go sub-elements rather than attributes just because of the number, but both are valid.
The fact of Qt Xml is neither here nor there for the decision, it will handle either as it should.