Silverlight XSD and datatable
-
I am using Silverlight 4 and WCF In the WCF I write a datatable to a stringreader and return the string to the UI. In the UI I need to turn the string into an object (Telerik datatable class) which requires that I read the elements to create the columns and the data to populate the rows. Problem is when the data has null values the xml does not get a full set of elements, the table is invalid in the UI. To solve this I want to include the schema in the string passed to the UI. However I cannot work out how to get the schema out of the xDocument. This receives the string and creates the xDocument, I then need to get the schema to create the columns
void GenericProcedureCompleted(object sender, GenericProcedureCompletedEventArgs e)
{
svcClient.GenericProcedureCompleted -= new EventHandler<GenericProcedureCompletedEventArgs>(GenericProcedureCompleted);
ShowError(e.sErrorMsg);
if (!string.IsNullOrEmpty(e.Result))
{
System.IO.StringReader sr = new System.IO.StringReader(e.Result);
XDocument xDoc = XDocument.Load(sr);
CreateTable(xDoc);
}
}This is currently using the elements to create the table
xEl = xDoc.Descendants("XMLData").ToList()[0];
foreach (XElement xe in xEl.Elements())
{
oCol = new CTUI.Data.DataColumn();
oCol.ColumnName = xe.Name.LocalName;
oCol.DataType = typeof(string);
dtData.Columns.Add(oCol);
}Ant suggestions that are valid for Silverlight 4 will be welcome. Note Silverlight 4 does not support all xml structures.
Never underestimate the power of human stupidity RAH