This LINQ to XML query should be close to what you are doing:
XElement xml = new XElement("contacts", new XElement("contact", new XAttribute("contactId", ""), new XElement("firstName", ""), new XElement("lastName", ""), new XElement("Address", new XElement("Street", "")) ),
new XElement("contact", new XAttribute("contactId", ""), new XElement("firstName", ""), new XElement("lastName", "") ) );
var query = from c in xml.Elements() where c.Value != "" select c;
Console.WriteLine(xml); Console.WriteLine(query.Count());
When the request counter == 0, you have no content items.
Depending on what you need, and if you don't have other uses for manipulating LINQ styles, the xPath solution posted may be better suited.
source share