The XslTransform. Transform method outputs the result to a string in two ways:
Implemented through the System. IO. MemoryStream class.
Implemented through the System. Text. StringBuilder class.
The specific implementation method is as follows:Copy codeThe Code is as follows: System. Xml. Xsl. Pipeline transform RssXslt = new System. Xml. Xsl. Pipeline transform ();
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. Pipeline transform RssXslt = new System. Xml. Xsl. Pipeline transform ();
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 );