私は次のようなXMLを持っています:
<RES>
<MUL>
<SIN>
<KEY name="a">
<VALUE>a1</VALUE>
</KEY>
<KEY name="b">
<VALUE>b1</VALUE>
</KEY>
<KEY name="c">
<VALUE>c1</VALUE>
</KEY>
<KEY name="need">
<MUL>
<SIN>
<KEY name="needID">
<VALUE>ID</VALUE>
</KEY>
<KEY name="needOther">
<VALUE>other</VALUE>
</KEY>
<KEY name="needOther2">
<VALUE>other2</VALUE>
</KEY>
</SIN>
</MUL>
</KEY>
</SIN>
</MUL>
</RES>
needID
私の質問は、名前が?のノードから値 'id' を取得する方法です。
で試しました
XmlDocument xx = new XmlDocument();
xx.Load(MYDOC);
XmlNodeList node = xx.SelectNodes("/RES/MUL/SIN/KEY[@name='need']");
しかし、その後、needIDを選択できません
XDocument doc = new XDocument(node);
var cource = from x in doc.Descendants("KEY")
select new { ID = doc.Element("VALUE").Value };
私を助けてください!
ありがとう!:)