Loading XML to DataSet tables in .Net 4 / VS2010 not loading all elements /attributes
I am trying to load a complex XML document to DataSet Tables. Here is the code that validates the xml with xsd document and trying to load to the dataset tables:
DataSet ds = new DataSet();
ds.ReadXmlSchema("test.xsd");
ds.EnforceConstraints = true;
ds.ReadXml("test.xml", XmlReadMode.ReadSchema);
And after this I tried to see all table tables/ columns created using the below code"
foreach (DataTable x in ds.Tables) {
Console.WriteLine("TableName: {0}", x.TableName);
foreach (DataColumn dc in x.Columns) {
Console.WriteLine(" column: {0} , DataType: {1}",
dc.ColumnName, dc.DataType);
}
}
In the printed Tables/columns output I could not see few elements / attributes that are in the XSD. When I moved around those Xs:element sections that are no in the output with the ones that are in the output, now the output shows the ones which were not earlier and did not show the ones which was there before... I would appreciate any help/ideas...
the xsd is about 50K and the xml is about 200K , not sure if they could be uploaded/pasted in he开发者_运维问答re...
Thanks Sankar
It might be easier to start with the DataTable you desire and then create the xsd schema from it:
As shown here.
精彩评论