Inference Limitations (ADO.NET)
The process of inferring a DataSet schema from XML can result in different schemas depending on the XML elements in each document. For example, consider the following XML documents.
Document1:
<DocumentElement>
<Element1>Text1</Element1>
<Element1>Text2</Element1>
</DocumentElement>
Document2:
<DocumentElement>
<Element1>Text1</Element1>
</DocumentElement>
For "Document1," the inference process produces a DataSet named "DocumentElement" and a table named "Element1," because "Element1" is a repeating element.
DataSet: DocumentElement
Table: Element1
Element1_Text |
---|
Text1 |
Text2 |
However, for "Document2," the inference process produces a DataSet named "NewDataSet" and a table named "DocumentElement." "Element1" is inferred as a column because it has no attributes and no child elements.
DataSet: NewDataSet
Table: DocumentElement
Element1 |
---|
Text1 |
These two XML documents may have been intended to produce the same schema, but the inference process produces very different results based on the elements contained in each document.
To avoid the discrepancies that can occur when generating schema from an XML document, we recommend that you explicitly specify a schema using XML Schema definition language (XSD) or XML-Data Reduced (XDR) when loading a DataSet from XML. For more information about explicitly specifying a DataSet schema with XML Schema, see Deriving DataSet Relational Structure from XML Schema (XSD).
See Also
Concepts
Loading a DataSet from XML (ADO.NET)
Loading DataSet Schema Information from XML (ADO.NET)
Other Resources
Inferring DataSet Relational Structure from XML (ADO.NET)
Using XML in a DataSet (ADO.NET)