// 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 { public class Program { public static void TopList(int from, int to) { Console.WriteLine("TopList " + from + " " + to); } public static void Echo(String val) { Console.WriteLine("Echo " + val); } public static void Process(string xml) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); string function = doc.SelectSingleNode("/request/function/text()").Value; XmlNode n = doc.SelectSingleNode("/request/parameters"); switch(function) { case "TOPLIST": int from = int.Parse(n.SelectSingleNode("from/text()").Value); int to = int.Parse(n.SelectSingleNode("to/text()").Value); TopList(from, to); break; case "ECHO": string val = n.SelectSingleNode("val/text()").Value; Echo(val); break; default: throw new Exception("Unknown function"); } } public static void Main(string[] args) { string s1 = @" TOPLIST 1 2 "; string s2 = @" ECHO ABC "; Process(s1); Process(s2); } } }