I have below xml. I want to delete those nodes which doesn't contains attributes. in below xml I want to delete last 4 nodes which doesn't have attributes.
XML
<products>
<product system="kn-movies" code="UR">Unrated</product>
<product system="mu-movies" code="UR">Unrated</product>
<product system="na-movies" code="UR">Unrated</product>
<product system="fj-movies" code="UR">Unrated</product>
<product>Unrated (Unrated )</product>
<product>Unrated (Unrated )</product>
<product>Unrated (Без классификации )</product>
<product>Unrated (غير مصنف )</product>
</products>
I had tried this c# code
var ratingNode = document.Descendants("rating").Where(t => t != null && t.Equals(Convert.ToString(nodeItem))).FirstOrDefault();
if (ratingNode != null)
{
ratingNode.Remove();
}
but it doesn't worked for me. please help me out where i m doing mistakes.