我在c#:
中使用此控件创建了一个普通的xml文件XmlTextWriter writer = new XmlTextWriter("XMLFile.xml", System.Text.Encoding.UTF8);
&安培;该文件已正确创建,并具有特定的标签&一切。 [我跟着这个tutorial]
但我希望该文件在线发送,以便其他服务可以使用....
所以,我试过这个:
XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8);
但是这会在浏览器上输出一个没有任何标签的奇怪文件...那么如何将文件流作为普通的xml文件?
答案 0 :(得分:1)
XmlTextWriter writer = new XmlTextWriter(Response.OutputStream,System.Text.Encoding.UTF8); writer.WriteStartDocument(真); writer.Formatting = Formatting.Indented; writer.Indentation = 2;
writer.WriteStartElement("table");
createNode("1","Product 1","1000",writer);
createNode("2", "Product 2", "2000", writer);
createNode("3", "Product 3", "3000", writer);
createNode("4", "Product 4", "4000", writer);
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
Response.ContentType = "text/xml";
Response.End(); --------did you remember that part?