Default.xml 檔案
<?xml version="1.0" encoding="utf-8" ?>
<data>
.... 略
</data>
程式
String XMLnode = Server.MapPath("Default.xml");// 抓取參數資料
System.Xml.XmlDocument dom = new System.Xml.XmlDocument();
dom.Load(XMLnode); //可讀文件
System.Xml.XmlNodeList strXml = dom.SelectSingleNode("data").ChildNodes;
for (int index = 0; index <= strXml.Count - 1; index++)
{
System.Xml.XmlNodeList strXmls = strXml.Item(index).ChildNodes;
for (int i = 0; i <= strXmls.Count - 1; i++)
{
System.Xml.XmlElement xe2 = (System.Xml.XmlElement)strXmls.Item(i); //轉換類型
Response.Write("<" + xe2.Name + ">" + xe2.InnerText + "<" + xe2.Name + ">");
}
Response.Write("<br>");
}
Response.Write("<br>");
Response.Write("<br>");
留言列表