XmlTextWriter类可以把XML写入一个流、文件或TextWriter对象中
2007-11-08 17:11
281 查看
private void button2_Click(object sender, System.EventArgs e)
{
string filename = "booknew.xml";
XmlTextWriter tw = new XmlTextWriter(filename,null);
tw.Formatting = Formatting.Indented;
tw.WriteStartDocument();
tw.WriteStartElement("book");
tw.WriteAttributeString("genre","Mystery");
tw.WriteAttributeString("publicationdate","2001");
tw.WriteAttributeString("ISBN","123456789");
tw.WriteElementString("title","Case of the Missing Cookie");
tw.WriteStartElement("author");
tw.WriteElementString("name","Cookie Monster");
tw.WriteEndElement();
tw.WriteElementString("price","9.99");
string ss="hello world";
tw.WriteStartElement("hello");
tw.WriteCData(ss);
tw.WriteEndElement();
tw.WriteStar
tw.WriteEndElement();
tw.WriteEndDocument();
tw.Flush();
tw.Close();
}
{
string filename = "booknew.xml";
XmlTextWriter tw = new XmlTextWriter(filename,null);
tw.Formatting = Formatting.Indented;
tw.WriteStartDocument();
tw.WriteStartElement("book");
tw.WriteAttributeString("genre","Mystery");
tw.WriteAttributeString("publicationdate","2001");
tw.WriteAttributeString("ISBN","123456789");
tw.WriteElementString("title","Case of the Missing Cookie");
tw.WriteStartElement("author");
tw.WriteElementString("name","Cookie Monster");
tw.WriteEndElement();
tw.WriteElementString("price","9.99");
string ss="hello world";
tw.WriteStartElement("hello");
tw.WriteCData(ss);
tw.WriteEndElement();
tw.WriteStar
tw.WriteEndElement();
tw.WriteEndDocument();
tw.Flush();
tw.Close();
}
相关文章推荐
- 序列化反序列化对象XML文件写入Sample,简单但是有代表性
- 在androidMainfest.xml文件中在此Activity中写入 android:windowSoftInputMode="adjustPan" 可以让界面不被弹出的键盘挤上去。
- 使用了博客园的备份后得到一个xml文件,不知道有没有css或者xslt文件可以在本地阅读文章,在网上找了半天也没有找到解决办法,难道要自己写?
- 向文件中写入Hashmap对象,且可以追加写的方法~~试了很多类了,最后得到的方法
- js文件中声明的一个json对象, 在另一个js文件中可以直接使用。
- 一个简单的xml类,可以解析和生成xml文件数据
- 使用XlmWrite把一个xml文件写入输出流中。在(demo2.aspx运行时显示xml文档)
- android面试题总结02 在android中本地写入一个xml文件
- 完成一个学生管理程序,使用学号作为键添加5个学生对象,并可以将全部信息保存在文件中,可以实现对学生信息的学号查找,输出全部学生信息的功能。
- 完成一个学生管理程序,使用学号作为键添加5个学生对象,并可以将全部信息保存在文件中,可以实现对学生信息的学号查找,输出全部学生信息的功能。
- 在androidMainfest.xml文件中在此Activity中写入 android:windowSoftInputMode="adjustPan" 可以让界面不被弹出的键盘挤上去。
- 使用XlmWrite把一个xml文件写入输出流中在(demo2.aspx运行时显示xml文档)
- 有关对象流写入读取文件的一个细节
- Android中其中一个Activity可以对另一个Activity的xml文件中的EditText设置进行设置吗?
- python 把一个文本文件中的语句分词, 并去重,然后写入一个CSV文件后,你可以排序
- xml文件生成方式一(字符串拼接,将多实体类对象写入xml文件)
- 跨域文件crossdomain.xml在weblogic上的部署和http://10.165.26.151:7001/xx.xml可以访问一个文件
- 完成一个学生管理程序,使用学号作为键添加5个学生对象,并可以将全部信息保存在文件中,可以实现对学生信息的学号查找,输出全部学生信息的功能。
- java.io,PrintWriter可以用来创建一个文件并向本文文件写入数据
- org.apache.commons.configuration.XMLConfiguration 可以用来读取和写入 xml 文件