xml及dataset的一些小記

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);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章