When to Use W3C XML Schema
You should probably create XML Schema for your XML documents if any of the following apply:
The order and number of nodes in your document must be constrained.
The data within your document’s nodes must be constrained more specifically than a DTD allows.
You wish to generate code to read and write XML to and from .NET types or a relational database using
XmlSerializer
orXmlDataDocument
.
Conversely, you should strongly consider sticking with validation by DTD only if all of the following apply:
Nodes may appear in your XML document in any order and number.
The data in your document’s nodes may be free-form, and need not be constrained.
You will be reading and writing data to and from XML documents only using
XmlReader
,XmlWriter
,XmlDocument
,XPathDocument
, and the other built-in .NET XML types.
Get .NET & XML now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.