I have this xml-file:
<objects>
<object>
<value>test</value>
</object>
<object>
<value>foo</value>
</object>
<object>
<value>bar</value>
</object>
</objects>
Now, I want to query this xml, and retrieve all the object-elements where the text in the value-element = “foo”
Is there a easy way of doing this?
I have tried something like this:
var objects = from e in xml.Elements("value")
where e.Value.Equals("foo", StringComparison.OrdinalIgnoreCase)
select e.parent;
That does not work..
I think you’re looking for
xml.Elements() just returns child elements… if xml is your root XDocument, it wouldn’t return anything.