Is there a DLR-enabled XML navigation and reading class available in .NET 4.0? For example, imagine I have this XML:
<foo>
<bar>foobar is here</bar>
<bar>foobar is also here</bar>
<baz>foobar is not here</bar>
</foo>
Is there an easy way to navigate through this XML like this:
var doc = SomeDlrEnabledParser.Parse (xmlString);
foreach (var node in doc.foo.bar)
{
if (node == "foobar is here")
DoSomething();
else
DoSomethingElse();
}
I can see lots of reasons why the approach above would be problematic, including namespaces, attributes vs. elements, differentiating collections vs. single elements, encoded XML vs text, etc.
But much of the XML I deal with is very simple and read-only, and I'd be willing to accept sensible default behaviors in exchange for avoiding the "parentheses and quote soup" that's characteristic of working with simple XML in a pre-4.0 world.
For example, the "dot" operator could check attribute names before subelement names. Or non-collection operations would be automatically applied to the first element (like jQuery does).
Does the .NET 4.0 Framework Class Library contain anything like this? if not, any recommendations for a good open-source project or sample of a DLR-enabled XML library?