未知の深さと、XMLで子ノードの値を取得します。私はこのようなXMLを取得
<menu>
<is>
<not>
<l>Title</l>
<s>url1</s>
<t>1</t>
<is>
<hlua>
<l>Title</l>
<s>url2</s>
<t>0</t>
<is>
<frme>
<l>Title</l>
<s>url3</s>
<t>1</t>
</frme>
</is>
</hlua>
<chrj>
<l>Title</l>
<s>url4</s>
<t>1</t>
<is>
<cgas>
<l>Title</l>
<s>url5</s>
<t>1</t>
<is>
<el12>
<l>Title</l>
<s>url6</s>
<t>1</t>
</el12>
</is>
</cgas>
<cael>
<l>Title</l>
<s>url7</s>
<t>0</t>
</cael>
</is>
</chrj>
</is>
</not>
</is>
<menu>
私は、ノードの名前だけを子ノードの名前を知らない「メニュー」 。 私は値ノードのリストを取得したいウォールド:「s」はそのノード「T」= 1であれば、彼の親ノード「T」の場合= 1
私はこのリストを取得したいと思います:
-
XMLの例では
- url5
- url6
どうすればよいのでしょうか? LINQでこれを行いますか?
ありがとうございます!
私はこれは私の質問を解決思う:
List<XElement> listurls = (from elements in xe.Descendants()
//Elemento
let t_element = elements.Element("t")
let t_element_value = t_element != null ? t_element.Value : String.Empty
//Elemento Padre
let parent_element = elements.Parent.Parent
let t_element_parent = parent_element.Element("t")
let t_element_parent_value = t_element_parent != null ? t_element_parent.Value : "1"
where t_element_value.EndsWith("1") && t_element_parent_value.EndsWith("1") && elements.Element("u").Value!="#" && elements.Element("u").Value != ""
select elements.Element("u")).ToList();
は依然として問題ですか、解決策を見つけましたか? –