XML parse check if attribute exist

You can try this and see if there is any improvement

class xmlAttributes
{
    public string Node;
    public Dictionary<string, string> Attributes;
} 

Now with this LINQ,all attributes are stored in a dictionary(per Node) and could be accessed through the attribute name.

var Result = XElement.Load("somedata.xml").Descendants("spec")
                      .Select(x => new xmlAttributes
                      {
                          Node = x.Name.LocalName,
                          Attributes = x.Attributes()
                                     .ToDictionary(i => i.Name.LocalName,
                                                        j => j.Value)
                      });

Checks if an attribute exists on all XML Nodes

var AttributeFound = Result.All(x => x.Attributes.ContainsKey("AttrName"));

Checks if the attribute appears at least once

var AttributeFound = Result.Any(x => x.Attributes.ContainsKey("AttrName"));

Solved! No extra method needed:

countObject = spec.Attribute("mep_count") != null ? spec.Attribute("mep_count").Value : "False",