<?xml version="1.0" encoding="utf-8"?>
<Question>
<category ProblemCName="求职面试" KeyWord="简历,面试,跳槽,工作机会,礼仪,">
</category>
<category ProblemCName="职业规划" KeyWord="职业目标,发展前景,行业趋势,职业定位,晋升,测评,">
</category>
</Question>
怎么获取第一个 category 中的 KeyWord
己就是: 简历,面试,跳槽,工作机会,礼仪,
因为我写的这个xml第一个category的KeyWord会改变,
我的意思是:
获取[color=#00FF00]第一个 category 中的 KeyWord[/color]
<Question>
<category ProblemCName="求职面试" KeyWord="简历,面试,跳槽,工作机会,礼仪,">
</category>
<category ProblemCName="职业规划" KeyWord="职业目标,发展前景,行业趋势,职业定位,晋升,测评,">
</category>
</Question>
怎么获取第一个 category 中的 KeyWord
己就是: 简历,面试,跳槽,工作机会,礼仪,
因为我写的这个xml第一个category的KeyWord会改变,
我的意思是:
获取[color=#00FF00]第一个 category 中的 KeyWord[/color]
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 ;
}
xmlDoc.Load("xmlFile.xml");
string firstKeyword = xmlDoc.DocumentElement.ChildNodes[0].Attributes["KeyWord"].Value;
因为它是会改变的
你的哪各方法我也是会的