// 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.Xml; namespace E { class MainClass { public static void Main(string[] args) { string s1 = "

Navn*Cpr.nr.
Adresse*Tlf. primr*
Postnr.*Tlf. alternativ
By*Tlf. arbejde
Land*E-mail

"; XmlDocument docx = new XmlDocument(); docx.LoadXml(s1); XmlNodeList xnlx = docx.SelectNodes("//input"); Console.WriteLine(xnlx.Count); string s2 = "

Navn*Cpr.nr.
Adresse*Tlf. primr*
Postnr.*Tlf. alternativ
By*Tlf. arbejde
Land*E-mail

"; XmlDocument docy = new XmlDocument(); docy.LoadXml(s2); XmlNodeList xnly = docy.SelectNodes("//input"); Console.WriteLine(xnly.Count); XmlDocument docz = new XmlDocument(); docz.LoadXml(s2); XmlNamespaceManager xnm = new XmlNamespaceManager(docz.NameTable); xnm.AddNamespace("html", "http://www.w3.org/1999/xhtml"); XmlNodeList xnlz = docz.SelectNodes("//html:input", xnm); Console.WriteLine(xnlz.Count); } } }