For well-formedness I simply
try
to load it into an XmlDocument and
catch
the Exception.
You may be looking to
validate against a schema; that's a whole different matter.
But to keep it simple, rather than do what you have, look into XPath :
/Model/Object[@type='Book' and Component/Element/Article]
.
System.Xml.XmlDocument doc = new System.Xml.XmlDocument() ;
doc.Load ( "Book.xml" ) ;
System.Console.WriteLine ( doc.SelectNodes ( "/Model/Object[@type='Book' and Component/Element/Article]" ).Count ) ;