Revision: 15754
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 15, 2009 21:24 by rengber
Initial Code
public string TransformXML(string xml, string xslt) { string output = string.Empty; XPathDocument xpd = new XPathDocument(new StringReader(xml)); XslCompiledTransform transform = new XslCompiledTransform(true); transform.Load(new XmlTextReader(xslt, XmlNodeType.Document, null)); StringWriter sr = new StringWriter(); transform.Transform(xpd.CreateNavigator(), null, sr); output = sr.ToString(); return output; } //Note that the XSL needs namespace prefixes to make .Net happy: xsl = @"<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:output method='text'/> <xsl:template match='msg'>Found it!</xsl:template> </xsl:stylesheet>"; xml = @"<msg/>";
Initial URL
Initial Description
Initial Title
Minimalist XSLT Transform Using Two Strings
Initial Tags
xml, c
Initial Language
C#