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. Choosing XML element vs attribute

Choosing XML element vs attribute

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 374 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.
  • V Offline
    V Offline
    viniltc
    wrote on last edited by viniltc
    #1

    Hi All,

    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 reference (P or O). The node parameters are presented as a list of space separated variables. The parameter values are collected using widgets like spin box, vertical sliders etc.

    I'm a bit confused to determine the structure of the XML file recreates the above mentioned txt file. Should I use XML elements or XML attribute or combination of both to easily reconstruct?

    I really appreciate if someone can show me an example.

    Thanks in advance

    JonBJ 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • V viniltc

        Hi All,

        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 reference (P or O). The node parameters are presented as a list of space separated variables. The parameter values are collected using widgets like spin box, vertical sliders etc.

        I'm a bit confused to determine the structure of the XML file recreates the above mentioned txt file. Should I use XML elements or XML attribute or combination of both to easily reconstruct?

        I really appreciate if someone can show me an example.

        Thanks in advance

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @viniltc
        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 P or 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.

        1 Reply Last reply
        2

        • Login

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