Search code examples
c#linq.net-4.0linq-to-xmlxelement

Search a value in XELement


I have a tree in form of XML that stores it in XELement variable.How I can search a value in All Nodes in this XML and if it exists return true?


Solution

  • Try this:

    bool result = element.DescendantsAndSelf().Any(e => e.Value == "cccc");