> I need to transform an xml document, using xsl to a HTML output.
However, I need to transform everything from supplied strings. ie the
XML and XSL are provided as inputs (not the paths).
Any suggestions are appreciated. Thanks in advance.
See the code below...... I have avoided doing it with streams, which would
probably be a bit more efficient as using XmlDocument is a bit overkill
here, but this way should be more familiar to you given your past
experience.
Cheers
Chris
-------------------------------------------
Kognition Consulting Limited - Thought Meets Technology
Chris J.T. Auld - Managing Director
Microsoft MVP (Windows Mobile Devices)
Phone: +64 3 453 0064
Mobile: +64 21 500 239
Email:
ch***@spam.me.n ot.kognition.co .nz
using System;
using System.IO;
using System.Xml;
using System.Xml.XPat h;
using System.Xml.Xsl;
public class Foo
{
private const String sourceXml= @"<foo>bar</foo>";
private const String sourceXsl= @"<xsl:styleshe et version='1.0'
xmlns:xsl='http ://www.w3.org/1999/XSL/Transform'><xsl :template
match='/'>Your <xsl:value-of select='foo'/>
Here</xsl:template></xsl:stylesheet> ";
public static void Main()
{
XmlDocument xslDoc = new XmlDocument();
xslDoc.LoadXml( sourceXsl);
XslTransform xslt = new XslTransform();
xslt.Load(xslDo c.CreateNavigat or());
XmlDocument contentDoc = new XmlDocument();
contentDoc.Load Xml(sourceXml);
XmlTextWriter writer = new XmlTextWriter(C onsole.Out);
writer.Formatti ng=Formatting.I ndented;
xslt.Transform( contentDoc, null, writer, null);
}
}