XML attributes or node ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • R.A.F.

    #1

    XML attributes or node ?

    Hi,

    When i see a XML file i'm still wondering what are the differences
    between writing node data as node attributes or as children nodes.

    for example, what are the advantage to write such thing :
    <setting>
    <client>
    <name>Vaporex </name>
    <address>Sain t Hope st.</address>
    </client>
    </setting>

    instead of :
    <setting>
    <client name="Vaporex" address="Saint Hope st."></client>
    </setting>

    my question is the following one :
    - which XML structure make a node or attribute research faster ?


    Moreover, what should be written as attribute and what should be written
    as children node ?

    thanks a lot,

    RAF
  • Kerem Gümrükcü

    #2
    Re: XML attributes or node ?

    Hi RAF,
    >my question is the following one :
    >- which XML structure make a node or attribute research faster ?
    I dont have performance measures and experience on this
    since i never had to read "really" huge xml files. But i think
    this also heavily depends on the kind of xml parser you
    use. Dont ask me how the System.Xml Parser handles huge
    files. I store huge and important things inside a RDBMS like
    SQL Server, Oracle, or another proven and stable system
    not a xml file,...

    >Moreover, what should be written as attribute and what should be written as
    >children node ?
    This depends on the extensibillity of your application
    and sometimes it is a choice of style. It is sometimes
    the same with objects in OO Programming. You will
    have a vehicle class, it will have a child object that can be
    a car class and it can have attributes like a engine="V6"
    and its fuel="leaded" and four tires with attribute brand="bridgest one"
    then it can be extended with for seats and they will have the
    attributes like material = "leather" or color = "red". I am sure
    tthat you understand what i am talking about,...

    example:

    <vehicle>
    <car engine="V6" fuel="leaded" model="muscle car">
    <tires count="4" brand="bridgest one">
    <seats count="4" material="leath er" color="red">
    </seats>
    </tires>
    </car>
    </vehicle>

    Sure this is a simple example but it show the basic structure
    how this can be accomplished. The example can be completely
    reorganized but this depends, as i said on the extensibility of
    your application and how the "range" of your abstraction should
    be and how you want it to be,...


    Regards

    Kerem

    --
    -----------------------
    Beste Grüsse / Best regards / Votre bien devoue
    Kerem Gümrükcü
    Microsoft Live Space: http://kerem-g.spaces.live.com/
    Latest Open-Source Projects: http://entwicklung.junetz.de
    -----------------------
    "This reply is provided as is, without warranty express or implied."


    Comment

    • Dubravko Sever

      #3
      Re: XML attributes or node ?


      "R.A.F." <noemail@nospam .comwrote in message
      news:eVCLGO5LIH A.5400@TK2MSFTN GP04.phx.gbl...
      Hi,
      >
      When i see a XML file i'm still wondering what are the differences between
      writing node data as node attributes or as children nodes.
      >
      for example, what are the advantage to write such thing :
      <setting>
      <client>
      <name>Vaporex </name>
      <address>Sain t Hope st.</address>
      </client>
      </setting>
      >
      instead of :
      <setting>
      <client name="Vaporex" address="Saint Hope st."></client>
      </setting>
      >
      my question is the following one :
      - which XML structure make a node or attribute research faster ?
      >
      >
      Moreover, what should be written as attribute and what should be written
      as children node ?
      >
      Hi,

      It depends,
      It could be the same if you planning to use one atrribute with name "name"
      (it's simple to read), but in some situation you will have to use multiple
      (1..n) as :

      <client>
      <name>Vaporex </name>
      <name>Vaporex12 3</name>
      </client>

      Correct me if i'm wrong.

      D.S.


      Comment

      Working...