List<path> Report = new List<path>();
XmlDocument myCha = new XmlDocument();
try
{
myCha.Load(path);
}
catch (Exception e)
{
if (e != null)
{
return Report;
}
}
myCha.Load(path);
//2.获得根节点
XmlNode node = myCha.DocumentElement;
foreach (XmlNode ShowList in node.ChildNodes)
{
if (ShowList.Attributes[“state”].InnerText.ToString().Equals(“1”))
{
path report = new path();
foreach (XmlNode work in ShowList.ChildNodes)
{

switch (work.Name)
{

case “ip”:
report.ip = work.InnerText;
break;
case “ku”:
report.ku= work.InnerText;
break;
case “name”:
report.name = work.InnerText;
break;
case “passwrod”:
report.passwrod = work.InnerText;
break;
}
}
Report.Add(report);
}
}
return Report;
}

版权声明:本文为zchbiji原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/zchbiji/p/9039911.html