C#DOM读XML文件
public void LoadXML()
{
XmlDocument doc = new XmlDocument();
doc.Load("ArticleConfig.xml");
XmlNode rootNode = doc.DocumentElement;
foreach (XmlNode subNode in rootNode.ChildNodes)
{
switch (subNode.Name)
{
case "startID":
art.StartID = Convert.ToInt32(subNode.InnerText);
break;
case "endID":
art.EndID = Convert.ToInt32(subNode.InnerText);
break;
case "currentID":
art.CurrentID = Convert.ToInt32(subNode.InnerText);
break;
case "step":
art.Step = Convert.ToInt32(subNode.InnerText);
break;
case "url":
art.Url = subNode.InnerText;
break;
case "type":
art.ArticleType = subNode.InnerText;
break;
case "savePath":
hdl.SavePath = subNode.InnerText;
break;
case "titleTag":
hdl.TitleTagName = subNode.InnerText;
break;
case "titleClass":
hdl.TitleClassName = subNode.InnerText;
break;
case "titleID":
hdl.TitleID = subNode.InnerText;
break;
case "txtTag":
hdl.TxtTagName = subNode.InnerText;
break;
case "txtClass":
hdl.TxtClassName = subNode.InnerText;
break;
case "txtID":
hdl.TxtID = subNode.InnerText;
break;
case "replace":
hdl.Replace = subNode.InnerText.Split(',');
break;
}
}
}