string XMLnode = "";
XMLnode += "<data>";
XMLnode += "<intro>";
XMLnode += "<day>1</day>";
XMLnode += "<text>第一筆資料</text>";
XMLnode += "</intro>";
XMLnode += "<intro>";
XMLnode += "<day>2</day>";
XMLnode += "<text>第二筆資料</text>";
XMLnode += "</intro>";
XMLnode += "</data>";
System.Xml.XmlDocument dom = new System.Xml.XmlDocument();
dom.LoadXml(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>");
留言列表