でXML-値の一部を取得しますか?私のようなXMLを持つC#の
は私が
XmlDocument xx = new XmlDocument();
xx.Load(MYDOC);
XmlNodeList node = xx.SelectNodes("/RES/MUL/SIN/KEY[@name='need']");
てみましたが、その後、私は、私を助けてください
XDocument doc = new XDocument(node);
var cource = from x in doc.Descendants("KEY")
select new { ID = doc.Element("VALUE").Value };
でneedIDを選ぶことはできません!
ありがとうございます!
// you're expecting only a single node - right?? So use .SelectSingleNode!
XmlNode node = xx.SelectSingleNode("/RES/MUL/SIN/KEY[@name='need']");
// if we found the node...
if(node != null)
{
// get "subnode" inside that node
XmlNode valueNode = node.SelectSingleNode("MUL/SIN/KEY[@name='needID']/VALUE");
// if we found the <MUL>/<SIN>/<KEY name='needID'>/<VALUE> subnode....
if(valueNode != null)
{
// get the inner text = the text of the XML element...
string value = valueNode.InnerText;
}
}
またはあなたが1つでもにそれを組み合わせることができ:
XDocument doc = XDocument.Load("url");
var cource = from x in doc.Descendants("KEY")
where x.Attribute("name").Value == "needID"
select new { ID = x.Element("VALUE").Value };
おかげ
ディープ
私はXElementオブジェクトと子孫を(使用を検討したい) –