Exception when loading partial xml data into xsd dataset

awailsott

New Member
I have the following .xsd code:\[code\]<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" id="MyDataSet"> <xs:element name="Row"> <xs:complexType> <xs:sequence> <xs:element name="Number" type="xs:int"/> <xs:element name="Item" type="xs:string"/> <xs:element name="Comment" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element></xs:schema>\[/code\]And the following .xml file:\[code\]<?xml version="1.0" standalone="yes"?><MyDataSet> <Row> <Number>1</Number> <Item>first</Item> </Row> </MyDataSet>\[/code\]Since the "Comment" tag is missing in the xml file, I get an exception when running:\[code\]MyDataSet myDataSet = new MyDataSet();myDataSet.ReadXml(xmlFilePath);\[/code\]The exception is: "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."How can I define the .xsd to be able to receive partial xml data and fill null or any default value when a tag is missing?
 
Back
Top