(原创)XML读取方法
public string bmxmltest(string id)
{
string name = "";
XmlNodeList xnl = xmlDoc.DocumentElement.ChildNodes;
foreach (XmlNode xn in xnl)
{
for (int i = 0; i < xn.Attributes.Count; i++)
{
XmlAttribute xa = xn.Attributes[i];
if (xa.Name == "id" && xa. == "zyf")
{
name = xn.InnerText;
}
}
}
return name;
}
---------------------------------------
public string bmtest(string type)
{
string className = "";
XmlNodeList xnl = xmlDoc.DocumentElement.ChildNodes;
foreach(XmlNode xn in xnl)
{
if (xn.FirstChild.InnerText == type)
{
className = xn.ChildNodes[1].InnerText;
}
}
return className;
}