我有一个这样的xml文件......
<AnimationPackage>
<condition>
<name>Some Condition 0</name>
<url>http://www.google.com.pk</url>
<rehab>
<name>Some rehab 0</name>
<url>http://www.youtube.com</url>
</rehab>
<rehab>
<name>Some rehab 1</name>
<url>http://www.youtube.com</url>
</rehab>
<rehab>
<name>Some rehab 2</name>
<url>http://www.youtube.com</url>
</rehab>
</condition>
<condition>
<name>Some Condition 1</name>
<url>http://www.google.com.pk</url>
<rehab>
<name>Some rehab 0</name>
<url>http://www.youtube.com</url>
</rehab>
<rehab>
<name>Some rehab 1</name>
<url>http://www.youtube.com</url>
</rehab>
如何计算标签名称也像 Atfirst<Conditions>
然后<rehab>
For that condtions 然后来自<rehab>
标签的内部文本<name>
和<url>
标签。我试过这个,但在第一次阅读它不起作用..任何帮助PLZ。
XmlDocument readDoc = new XmlDocument();
readDoc.Load(MapPath("JkGroups.xml"));
conditions = readDoc.SelectNodes("AnimationPackage/condition").Count;
rehab = readDoc.SelectNodes("AnimationPackage/condition/rehab").Count;
lblApptitle.Text = dt.Rows[0]["packageName"].ToString();
XmlNodeList nodeListName = readDoc.SelectNodes("AnimationPackage/condition/rehab/name");
XmlNodeList nodeListUrl = readDoc.SelectNodes("AnimationPackage/condition/rehab/url");
for (rehabCount = 0; rehabCount < rehab; rehabCount++)
{
rehabNodeName = nodeListName[0].ChildNodes[rehabCount].InnerText;
rehabNodeUrl = nodeListUrl[0].ChildNodes[rehabCount].InnerText;
rehabtr += "<tr><td style='width: 106px;padding-left: 20px;' >Rehab title</td><td>"
+ "<input type='text' value='" + rehabNodeName + "' id='txtRehabSupportTitle" + rehabCount + "' runat='server' /></td><td>"
+ "<input type='text' value='" + rehabNodeUrl + "' id='txtRehabSupportURL" + rehabCount + "' runat='server' /></td></tr>";
}
string rehabBody = "<table id='tblRehab'>" + rehabtr + "<tr><td></td><td></td><td><p>Type support product buy URL</p></td></tr><tr>"
+ "<td><td> </td><td> </td></tr></table>";
缺少一些代码,但我只想在 xml 中提供帮助。