XML attribute vs XML element

前端 未结 20 2244
暖寄归人
暖寄归人 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:03

    Just a couple of corrections to some bad info:

    @John Ballinger: Attributies can contain any character data. < > & " ' need to be escaped to < > & " and ' , respectively. If you use an XML library, it will take care of that for you.

    Hell, an attribute can contain binary data such as an image, if you really want, just by base64-encoding it and making it a data: URL.

    @feenster: Attributes can contain space-separated multiple items in the case of IDS or NAMES, which would include numbers. Nitpicky, but this can end up saving space.

    Using attributes can keep XML competitive with JSON. See Fat Markup: Trimming the Fat Markup Myth one calorie at a time.

提交回复
热议问题