DataSet newds = new DataSet();
DataTable newdt = dt.Copy(); newdt.Namespace = "PortfolioInfo"; System.Type typestring = System.Type.GetType("System.String"); DataColumn colum = new DataColumn("XrayType", typestring); newdt.Columns.Add(colum); newdt.Rows[0]["XrayType"] = lblRiskType.Text; newds.Tables.Add(newdt);
newds.Tables.Add(dtXray.Copy()); newds.Tables.Add(top10set.Tables[0].Copy()); newds.Tables.Add(top5Bond.Tables[0].Copy()); newds.Tables.Add(PortfolioSector.Tables[0].Copy()); newds.WriteXml(Server.MapPath("test.xml"));
XmlDocument pdfdoc = new XmlDocument(); string path = Server.MapPath(xmlpath); doc.Load(path); XmlNode nameinfo = doc.SelectSingleNode("//NewDataSet"); XmlElement Portinfo = doc.CreateElement("PortInfo"); XmlNode nodeuname = doc.CreateNode(XmlNodeType.Element, "UserName", ""); nodeuname.InnerText = name; XmlNode EffectiveDate = doc.CreateNode(XmlNodeType.Element, "ReportDate", ""); EffectiveDate.InnerText = DateTime.Now.ToString("yyyy-MM-dd"); Portinfo.AppendChild(nodeuname); Portinfo.AppendChild(EffectiveDate); nameinfo.AppendChild(Portinfo); doc.Save(path);