本文介绍了格式化XML以在ASP.NET页上显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在sqlserver中有一个表,在该表中我有一列具有xml文件的列.我在gridview中显示该表.当我们单击按钮时,我想以xml格式显示特定的xml文件列或导出为xml文件格式.

I have a table in sqlserver, in that table i have a column having xml file. i am displaying that table in gridview. when we click on button i want to display that particular xml file column in a xml format or export to xml file format.

推荐答案

您可以实现

dtbl.WriteXml(Server.MapPath("~/yourSample.xml"));

或者可以

String xml = dtbl.Rows[0]["XMLColumnName"].ToString();
string filename = System.Web.HttpContext.Current.Server.MapPath("~/yourSample.xml");
XmlDocument xmlDoc = new XmlDocument();
XmlTextWriter xmlWriter = new XmlTextWriter(filename, System.Text.Encoding.UTF8);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
xmlWriter.WriteRaw(xml);
xmlWriter.Flush();
xmlWriter.Close();

这篇关于格式化XML以在ASP.NET页上显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 19:39