Re: [問題] 關於 XML

作者: GoalBased (Artificail Intelligence)   2014-09-23 14:34:31
: <a>
: <b id="1">
: <c name="apple">
: </c>
: </b>
: <b id="2">
: <c name="banana">
: </c>
: </b>
: </a>
已經找到解決方法,自己來回一下,
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("data.xml"));
XmlNode aRoot = doc.SelectSingleNode("a");
XmlNodeList aNodeList = root.ChildNodes;
foreach (XmlNode node in aNodeList)
{
XmlNode bRoot = node;
XmlNodeList bNodeList = nRoot.ChildNodes;
TextBox1.Text += "我是B,id=" + bRoot.Attributes["id"].Value + "\n";
foreach (XmlNode node in bNodeList)
{
XmlNode cRoot = node;
TextBox1.Text += "我是C,name="
+ cRoot.Attributes["name"].Value + "\n";
}
}
也謝謝來信的板友,感恩喔

Links booklink

Contact Us: admin [ a t ] ucptt.com