// 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; using System.Xml.XPath; using System.Xml.Xsl; namespace E { public class Util { public string DocType() { return @""; } } public class MainClass { public static void Main(string[] args) { string input = @" ABC "; string transform = @" Demo

Data =

"; XmlDocument doc = new XmlDocument(); doc.LoadXml(input); XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load(new XmlTextReader(new StringReader(transform)), new XsltSettings(true, true), null); StringWriter sw = new StringWriter(); XmlTextWriter wrt = new XmlTextWriter(sw); wrt.Formatting = Formatting.Indented; XsltArgumentList xal = new XsltArgumentList(); xal.AddExtensionObject("urn:arne:cs", new Util()); xslt.Transform(doc, xal, wrt); Console.WriteLine(sw.ToString()); } } }