// 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; using System.Text; namespace E { public class Program { public static void Main(string[] args) { string infnm = args[0]; string outfnm = args[1]; string splittag = args[2]; int n = 0; XmlReader xr = new XmlTextReader(infnm + ".xml"); XmlTextWriter xtw = null; while (xr.Read()) { if (xr.NodeType == XmlNodeType.Element && xr.Name == splittag) { n++; xtw = new XmlTextWriter(String.Format("{0}_{1:0000}.xml", outfnm, n), Encoding.UTF8); xtw.Formatting = Formatting.Indented; xtw.WriteStartDocument(); xtw.WriteNode(xr, false); xtw.WriteEndDocument(); xtw.Close(); } else { // ignore everything else } } xr.Close(); } } }