We just switched one of our larger applications from using .Net 1.1
to .Net 2.0. The XMLDocument XMLMainDoc is used heavily in the
application. One place we use it is in sending HTML emails. We
transform XMLMainDoc against some XSL and send the results as an
email. The old version of the code to get this transformed HTML as a
string was:
XslTransform xslt = new XslTransform();
xslt.Load(Server.MapPath("global.xsl"));
StringWriter MyResult = new StringWriter();
xslt.Transform(XMLMainDoc, null, MyResult, null);
string Result = MyResult.ToString();
Of course though System.Xml.Xsl.XslTransform is obselete. While the
code does compile and run just as well, is there a correct way to do
this so that I wind up with the same Result string?
Larry.
Martin Honnen - 28 Aug 2007 11:52 GMT
Larry Viezel wrote:
> XslTransform xslt = new XslTransform();
> xslt.Load(Server.MapPath("global.xsl"));
[quoted text clipped - 5 lines]
> code does compile and run just as well, is there a correct way to do
> this so that I wind up with the same Result string?
You should use System.Xml.Xsl.XslCompiledTransform instead, pseudo code
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(Server.MapPath("global.xsl"));
StringWriter myResult = new StringWriter();
xslt.Transform(XMLMainDoc, null, myResult);
string result = myResult.ToString();
See
<URL:http://msdn2.microsoft.com/en-us/library/system.xml.xsl.xslcompiledtransform.aspx>
and <URL:http://msdn2.microsoft.com/en-us/library/66f54faw.aspx>

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/