XmlTextWriter Csharp
来源:互联网 发布:新浪财经数据接口 编辑:程序博客网 时间:2024/04/27 19:51
private void XmlWriteTest()
{
string fileName="C://Test.xml";
XmlTextWriter writer = new XmlTextWriter (fileName, null);
//Use indenting for readability.
writer.Formatting = Formatting.Indented;
writer.WriteComment("sample XML fragment");
//Write an element (this one is the root).
writer.WriteStartElement("bookstore");
//Write the namespace declaration.
writer.WriteAttributeString("xmlns", "bk", null, "urn:samples");
writer.WriteStartElement("book");
//Lookup the prefix and then write the ISBN attribute.
string prefix = writer.LookupPrefix("urn:samples");
writer.WriteStartAttribute(prefix, "ISBN", "urn:samples");
writer.WriteString("1-861003-78");
writer.WriteEndAttribute();
//Write the title.
writer.WriteStartElement("title");
writer.WriteString("The Handmaid's Tale");
writer.WriteEndElement();
//Write the price.
writer.WriteElementString("price", "19.95");
//Write the style element.
writer.WriteStartElement(prefix, "style", "urn:samples");
writer.WriteString("hardcover");
writer.WriteEndElement();
//Write the end tag for the book element.
writer.WriteEndElement();
//Write the close tag for the root element.
writer.WriteEndElement();
//Write the XML to file and close the writer.
writer.Flush();
writer.Close();
//Read the file back in and parse to ensure well formed XML.
XmlDocument doc = new XmlDocument();
//Preserve white space for readability.
doc.PreserveWhitespace = true;
//Load the file
doc.Load(fileName);
//Write the XML content to the console.
MessageBox.Show(doc.InnerXml);
}
- XmlTextWriter Csharp
- XmlTextWriter
- csharp
- Csharp
- XmlTextWriter用法
- XmlTextWriter类
- XmlTextWriter 类
- XmlTextWriter类
- XmlDocument/XmlTextWriter
- XmlTextWriter学习笔记
- XmlTextWriter学习笔记
- 用XmlTextWriter追加记录
- 关于XmlTextWriter的使用方法
- XmlTextWriter创建XML文件
- .NET操作XML--XMLTextWriter
- XmlTextWriter学习总结
- XmlTextWriter函数用法
- XmlWriter与XmlTextWriter
- 潮汕语录
- >+ eBay架构的思想金矿
- 又大一岁
- 求助!精通特殊字符输入法的请进~
- 怎么由DataSet将数据导入Excel?
- XmlTextWriter Csharp
- 从数据库中读取记录的动态列表(无初始值)
- Struts menu
- Jbuilder I18N opentools
- 38所高校1953年来培养的两院院士
- 关于Java中文问题的几条分析原则及几篇相关文章
- 周总理开国大典上的录音(很珍贵哦)
- 三层结构简介
- 再生