Is there any difference between 'valid xml' and 'well formed xml'?

前端 未结 14 3022
清酒与你
清酒与你 2020-11-21 04:43

I wasn\'t aware of a difference, but a coworker says there is, although he can\'t back it up. What\'s the difference if any?

14条回答
  •  耶瑟儿~
    2020-11-21 05:45

    Well-Formed XML is XML that meets the syntactic requirements of the language. Not missing any closing tags, having all your singleton tags use instead of just , and having your closing tags in the right order.

    Valid XML is XML that uses a DTD and complies with all its requirements. So if you use an attribute improperly, you violate the DTD and aren't valid.

    All valid XML is well-formed, but not all well-formed XML is valid.

提交回复
热议问题