Monday, November 16, 2009

Converting XML to Type Dataset ( XSD )

//  Code to convert xml data to strongly typed dataset

XmlDocument xdoc = new XmlDocument();
xdoc.Load(Server.MapPath("test1.xml"));
DataSet ds = new DataSet();
byte[] bufe = System.Text.ASCIIEncoding.ASCII.GetBytes(xdoc.OuterXml);
System.IO.MemoryStream ms = new System.IO.MemoryStream(bufe);
ds.ReadXml(ms, XmlReadMode.InferSchema);
ms.Close();
ds.WriteXmlSchema(Server.MapPath("test1.xsd"));

No comments:

Post a Comment