What's the accepted way of storing quoted data in XML?

前端 未结 7 1263
攒了一身酷
攒了一身酷 2021-01-04 01:01

What\'s the accepted way of storing quoted data in XML?

For example, for a node, which is correct?

  • (a) Jesse \"The Body\" Ventura
7条回答
  •  没有蜡笔的小新
    2021-01-04 01:41

    Your correct answer is A & C as the " is not a character that must be encoded in element data.

    You should always be XML encoding characters such as >, <, and & to ensure that you don't have issues if they are NOT inside a CDATA section. These are key items to be concerned about for element data.

    When talking about attributes you have to then also be careful of ' and " inside attribute values depending on the type of symbol you use to surround the value.

    I've found that often encoding " and ' is a better idea in all aspects as it helps at times when converting to other formats, where the " or ' might cause problems there as well.

提交回复
热议问题