locked
XDocument.Descendants().Any(); missing RRS feed

  • Question

  • User750179529 posted

    Hello there,

    I try to find a way to check if a xml file has a Element with the name "mail".

    I found the hint to use 

    if (doc.Descendants().Any())
    {
    }

    but all I get is the error, <System.Xml.Linq.XElement> has no definition for "Any" ...

    Where is my mistake?? :(
    Is there a better way to check the Element?

    Thanks!!

    Doc

    Friday, July 17, 2015 6:54 AM

Answers

  • User2103319870 posted

    but all I get is the error, <System.Xml.Linq.XElement> has no definition for "Any" ...

    Where is my mistake?? :(

    Did you add the reference of Linq in your page

    using System.Linq;

    If above solution didnt work then  please provide your complete code to read the xml and a sample xmlfile content which you are using

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 17, 2015 11:05 AM