Convert XmlDocument to XElement

XmlElement x = objXmlDocument.documentElement;

You might need this if you are creating a WCF service that accepts XElement as parameter but user has a dataset to be converted to Xelement

XmlDocument xDoc = new XmlDataDocument(YourDataset);
XmlElement x = xDoc.DocumentElement;

example:
 DataSet ds = new DataSet();
 ds.Tables.Add("students"); ds.Tables[0].Columns.Add("Name");
 DataRow dr1 = ds.Tables[0].NewRow(); dr1[0] = "Alan"; ds.Tables[0].Rows.Add(dr1);
 XmlDocument xDoc = new XmlDataDocument(ds);
 XmlElement x = xDoc.DocumentElement;

Comments

Popular posts from this blog

How to show only month and year fields in android Date-picker?

How to construct a B+ tree with example

Conflict Serializability in database