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

前端 未结 14 2716
清酒与你
清酒与你 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:24

    As others have said, well-formed XML conforms to the XML spec, and valid XML conforms to a given schema.

    Another way to put it is that well-formed XML is lexically correct (it can be parsed), while valid XML is grammatically correct (it can be matched to a known vocabulary and grammar).

    An XML document cannot be valid until it is well-formed. All XML documents are held to the same standard for well-formedness (an RFC put out by the W3). One XML document can be valid against some schemas, and invalid against others. There are a number of schema languages, many of which are themselves XML-based.

提交回复
热议问题