Export (0) Print
Expand All

Creating XML Schemas from XML Files

Visual Studio .NET 2003

You create schemas based on existing XML files when you want to validate that other XML files conform to the same data structure and data type restrictions as the original XML file.

Tip   To create an ADO.NET dataset from an XML file, you must first create a schema and then generate a dataset from that schema. For more information, see Creating ADO.NET Typed Datasets from Schemas.
Note   There are some instances of XML documents that schemas and datasets cannot be created from. Although the XML would be considered well formed, trying to create a schema will generate a Failed to Create Schema error if the contents cannot be logically interpreted into structured data.

To create a new XML Schema based on an existing XML Document

  1. Load an XML document (.xml file) into the XML Designer.
  2. From the XML menu click Create Schema.

    An XML Schema (.xsd file) is added to the current project with the same name as the original XML file.

  3. Load the newly created XML Schema (.xsd file) into the XML Designer.
  4. Verify and edit the data types that were assigned when creating the schema.
    Note   When a schema is inferred from an existing XML document, all the data types are initially set to string, so you must edit the data types according to the content requirements of your XML data.
  5. If you need to make changes to the schema, you can use the XML Designer to add, edit, and remove elements.

Next Steps

See Also

XML Files | Creating New XML Files | Assigning Schemas to XML Files | Checking for Well-Formed and Valid XML | Relational Data in XML Schemas | Creating XML Schemas and Datasets | Introduction to Data Access with ADO.NET | Introduction to Datasets

Show:
© 2014 Microsoft