// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; using System.Xml; namespace E { public class Program { public static void Main(string[] args) { string xml = "1234"; XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); int nall = doc.SelectNodes("//*").Count; int nblobb = doc.SelectNodes("//blobb").Count; Console.WriteLine(nall - nblobb); int nnonblobb = 0; XmlReader xr = new XmlTextReader(new StringReader(xml)); while (xr.Read()) { if (xr.IsStartElement()) { if (xr.Name != "blobb") { nnonblobb++; } } } Console.WriteLine(nnonblobb); } } }