XslTransform.Transform 将结果到里有2中办法:
- 通过System.IO.MemoryStream类来实现。
- 通过System.Text.StringBuilder类来实现。
下面是具体的实现方法:
System.XML.Xsl.XslTransform RssXslt = new System.XML.Xsl.XslTransform(); System.Xml.XmlDocument RssXml = new System.Xml.XmlDocument(); RssXslt.Load(Server.MapPath( " RssReader.xslt ")); RssXml.Load(Server.MapPath( " Rss.xml ")); System.IO.MemoryStream t = new System.IO.MemoryStream(); RssXslt.Transform(RssXml, null,t, null); string resultString = System.Text.UTF8Encoding.UTF8.GetString(t.ToArray()); Response.Write(resultString); System.Xml.Xsl.XslTransform RssXslt = new System.Xml.Xsl.XslTransform(); System.Xml.XmlDocument RssXml = new System.Xml.XmlDocument(); RssXslt.Load(Server.MapPath( " RssReader.xslt ")); RssXml.Load(Server.MapPath( " Rss.xml ")); System.Text.StringBuilder t = new System.Text.StringBuilder(); RssXslt.Transform(RssXml, null, new System.IO.StringWriter(t), null); string resultString = t.ToString(); Response.Write(resultString);