In XML, is order important?

后端 未结 11 2202
无人共我
无人共我 2020-11-28 11:25

Is the order that elements of a common parent appear in XML a meaningful piece of data captured by the XML document, or is order not specified as being meaningful? For examp

11条回答
  •  隐瞒了意图╮
    2020-11-28 12:02

    While XML attribute ordering is not significant as far as the XML standard is concerned, the textual representation of XML does by necessity place the attributes in a specific order. This can be an issue for things like XML Signature, which generates a digital signature for XML documents. A different attribute order would generate a different signature, which clearly is wrong.

    For this (and other) reasons, there is now a standard for XML Canonicalization, which defines rules for re-organising XML documents such that they retain the same information content, but have things like whitespace, namespace declarations and attributes rearranged in a predictable way.

    From xml.com

    Canonical XML requires the inclusion of namespace declarations and attributes in ascending lexicographic order.

提交回复
热议问题