// 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.Xml.XPath; namespace E { public class Program { public static XPathNodeIterator M1(XPathNodeIterator it) { XmlDocument doc = new XmlDocument(); doc.AppendChild(doc.CreateElement("newall")); while(it.MoveNext()) { doc.DocumentElement.AppendChild(doc.ImportNode((XmlNode)it.Current.UnderlyingObject, true)); } return doc.CreateNavigator().Select("."); } public static void M2(XPathNodeIterator it) { while(it.MoveNext()) { Console.WriteLine(it.Current.OuterXml); } } public static void Main(string[] args) { string xml = "ABBCCC"; XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); XPathNodeIterator res = M1(doc.CreateNavigator().Select("//all/one")); M2(res); } } }