XML attribute vs XML element

前端 未结 20 2586
暖寄归人
暖寄归人 2020-11-22 01:34

At work we are being asked to create XML files to pass data to another offline application that will then create a second XML file to pass back in order to update some of ou

20条回答
  •  醉梦人生
    2020-11-22 02:02

    This is very clear in HTML where the differences of attributes and markup can be clearly seen:

    1. All data is between markup
    2. Attributes are used to characterize this data (e.g. formats)

    If you just have pure data as XML, there is a less clear difference. Data could stand between markup or as attributes.

    => Most data should stand between markup.

    If you want to use attributes here: You could divide data into two categories: Data and "meta data", where meta data is not part of the record, you want to present, but things like "format version", "created date", etc.

    
         
         ...
    
    

    One could also say: "Use attributes to characterize the tag, use tags to provide data itself."

提交回复
热议问题