日期:2014-05-17 浏览次数:20789 次
private readonly string path = HttpContext.Current.Server.MapPath("XMLFile1.xml");
var doc = XDocument.Load(path);
IEnumerable<XElement> query = from a in doc.Elements("Question").Elements("category") where (string)a.Attribute("ProblemCName") == "求职面试" select a;
foreach (XElement item in query)
{
item.Element("KeyWord").Value ;
}
------解决方案--------------------
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("xmlFile.xml");
string firstKeyword = xmlDoc.DocumentElement.ChildNodes[0].Attributes["KeyWord"].Value;