XslTransform.Transform 方法将结果
输出到
字符串里有2中办法:
通过System.IO.MemoryStream类来实现。
通过System.Text.StringBuilder类来实现。
下面是具体的实现方法:
System.
xml.Xsl.XslTransform RssXslt = new System.
xml.Xsl.XslTransform();
System.
xml.
xmlDocument Rss
xml = new System.
xml.
xmlDocument();
RssXslt.Load(Server.MapPath("RssReader.xslt"));
Rss
xml.Load(Server.MapPath("Rss.
xml"));
System.IO.MemoryStream t = new System.IO.MemoryStream();
RssXslt.Transform(Rss
xml,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 Rss
xml = new System.
xml.
xmlDocument();
RssXslt.Load(Server.MapPath("RssReader.xslt"));
Rss
xml.Load(Server.MapPath("Rss.
xml"));
System.Text.StringBuilder t = new System.Text.StringBuilder();
RssXslt.Transform(Rss
xml,null,new System.IO.StringWriter(t),null);
string resultString = t.ToString();
Response.Write(resultString);