using System;
using System.Xml;
public partial class create_xml_string : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string xmlString = "<?xml version='1.0' encoding='UTF-8'?>";
xmlString += "<products>";
xmlString += "<product id='p3'>";
xmlString += "<name>Alpha</name>";
xmlString += "<price>1200</price>";
xmlString += "<stock>19</stock>";
xmlString += "<country>Germany</country>";
xmlString += "</product>";
xmlString += "</products>";
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlString);
doc.Save(Server.MapPath("products-string.xml"));
Response.Redirect("products-string.xml"); // load file in browser
}
}
Create XML with LoadXml(string) in ASP.NET
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
PacketiX.NET ***使用教程
雨的印記
2019-02-23 13:49:40
Excelize 釋出 2.3.0 版本,Go 語言 Excel 檔案基礎庫
xuri.me
2020-08-16 18:11:37
PHP5的XML新特性
talkstone
2019-02-23 13:59:02
XML Schema
lxxxxl
2019-02-23 00:28:31
Android平臺調用WebService詳解
推薦碼發放
2019-02-24 19:41:33
Spring Cloud Alibaba基礎教程:支持的幾種服務消費方式(RestTemplate、WebClient、Feign)
程序猿dd
2019-02-24 10:41:27
【Go】string 也是引用類型
thinkeridea
2019-02-24 08:04:44
【C++】 淺析深淺拷貝
Vs呂小布
2019-02-23 00:33:40
c++ string 類基本用法樣例
Iamlibby
2019-02-23 00:22:38
string類的寫時拷貝
xyzbaihaiping
2019-02-23 00:12:36
int 轉string
冰冰水晶
2019-02-23 00:08:25
string字符串排序
WenryXu
2019-02-22 23:55:25