总结asp.net 如何写入xml文件
2007-08-16 17:08
387 查看
总结asp.net 如何写入xml文件
1
DataSet myDst=new DataSet();
myDap.Fill(myDst,"aa");
FileStream fin ;
fin = new FileStream(Server.MapPath("aa.xml"),FileMode.Create,
FileAccess.ReadWrite, FileShare.ReadWrite);
ds.WriteXml(fin, XmlWriteMode.WriteSchema);
fin.Close();
2
private void WriteToXmlFile()
{
SqlConnection myCon=new SqlConnection("server=(local);database=test;uid=sa;pwd=");
string strCom="Select PKID,Name,FileType,FileLength From FileByField";
SqlDataAdapter myDap=new SqlDataAdapter(strCom,myCon);
myCon.Open();
//SqlDataReader drd=myDap.ExecuteReader();
DataSet myDst=new DataSet();
myDap.Fill(myDst,"aa");
FileStream myFS=new FileStream("a.xml",FileMode.OpenOrCreate);
XmlTextWriter myXwt=new XmlTextWriter(myFS,System.Text.Encoding.Unicode);
myDst.WriteXml(myXwt);
myXwt.Close();
//myFS.Flush();
dataGrid1.DataSource=myDst.Tables[0].DefaultView;
MessageBox.Show("写入完成");
}
3
string strfilename = server.mappath("create.xml");
xmldocument doc = new xmldocument();
doc.loadxml("<book genre=novel isbn=1-861001-57-5>" +
"<title>pride and prejudice</title>" +
"</book>");
//create an xml declaration.
xmldeclaration xmldecl;
xmldecl = doc.createxmldeclaration("1.0","shift-jis",null);
//add the new node to the document.
xmlelement root = doc.documentelement;
doc.insertbefore(xmldecl, root);
doc.save(strfilename);
1
DataSet myDst=new DataSet();
myDap.Fill(myDst,"aa");
FileStream fin ;
fin = new FileStream(Server.MapPath("aa.xml"),FileMode.Create,
FileAccess.ReadWrite, FileShare.ReadWrite);
ds.WriteXml(fin, XmlWriteMode.WriteSchema);
fin.Close();
2
private void WriteToXmlFile()
{
SqlConnection myCon=new SqlConnection("server=(local);database=test;uid=sa;pwd=");
string strCom="Select PKID,Name,FileType,FileLength From FileByField";
SqlDataAdapter myDap=new SqlDataAdapter(strCom,myCon);
myCon.Open();
//SqlDataReader drd=myDap.ExecuteReader();
DataSet myDst=new DataSet();
myDap.Fill(myDst,"aa");
FileStream myFS=new FileStream("a.xml",FileMode.OpenOrCreate);
XmlTextWriter myXwt=new XmlTextWriter(myFS,System.Text.Encoding.Unicode);
myDst.WriteXml(myXwt);
myXwt.Close();
//myFS.Flush();
dataGrid1.DataSource=myDst.Tables[0].DefaultView;
MessageBox.Show("写入完成");
}
3
string strfilename = server.mappath("create.xml");
xmldocument doc = new xmldocument();
doc.loadxml("<book genre=novel isbn=1-861001-57-5>" +
"<title>pride and prejudice</title>" +
"</book>");
//create an xml declaration.
xmldeclaration xmldecl;
xmldecl = doc.createxmldeclaration("1.0","shift-jis",null);
//add the new node to the document.
xmlelement root = doc.documentelement;
doc.insertbefore(xmldecl, root);
doc.save(strfilename);
相关文章推荐
- Asp.net中如何将DataSet写入xml文件,及如何将xml读出来绑定到DataGrid(原创)
- Asp.net中如何将DataSet写入xml文件,及如何将xml读出来绑定到DataGrid
- Asp.net中如何将DataSet写入xml文件,及如何将xml读出来绑定到DataGrid
- asp.net 如何写入xml文件
- (转载)Asp.net中如何将DataSet写入xml文件,及如何将xml读出来绑定到DataGrid 选择自 kgdiwss 的 Blog
- asp.net——网站发布后xml文件拒绝写入操作
- 项目开发中的一些注意事项以及技巧总结 基于Repository模式设计项目架构—你可以参考的项目架构设计 Asp.Net Core中使用RSA加密 EF Core中的多对多映射如何实现? asp.net core下的如何给网站做安全设置 获取服务端https证书 Js异常捕获
- kindeditor在asp.net中如何使用的总结
- 如何用在ASP.NET中写入事件日志
- Asp.net_关于如何利用编译器把[.cs]文件生成动态链接库[.dll]文件方法的总结
- Sql2012如何将远程服务器数据库及表、表结构、表数据导入本地数据库 自定义日志记录功能,按日记录,很方便 C#常量和字段以及各种方法的语法总结 类型,对象,线程栈,托管堆在运行时的关系,以及clr如何调用静态方法,实例方法,和虚方法 asp.net webapi 自定义身份验证
- ASP.NET中常用功能代码总结(6)——XML文件操作篇
- asp.net如何将页面Table控件中的数据写到excel中总结
- ASP.NET中常用功能代码总结(6)——XML文件操作篇
- 批量删除记录时如何实现全选方法总结 (转)http://www.cnblogs.com/chenou/articles/1349646.html[Asp.net Ajax 控件]
- ASP.NET中常用功能代码总结(4)——保存图片到XML文件
- 在ASP.NET中实现如何下载txt及xml文件的方法
- ASP.NET中常用功能代码总结(保存图片到XML文件)
- ASP.NET网站发布后xml文件拒绝写入操作
- asp.net中如何把应用程序错误写入事件日志(注册事件源)