public string TransformXML(string strXMLURL, string strXSLURL) { //Create a IO Stream System.IO.StringWriter oSW = new System.IO.StringWriter(); try { System.Xml.XmlTextReader oXR = new System.Xml.XmlTextReader(strXMLURL); System.Xml.Xsl.XslTransform oXSLT = new System.Xml.Xsl.XslTransform(); oXSLT.Load(strXSLURL); System.Xml.XPath.XPathDocument oXPath = new System.Xml.XPath.XPathDocument(oXR); oXSLT.Transform(oXPath,null,oSW); } catch (System.Exception e) { //Put in custom error handler here... string x = e.ToString(); } return oSW.ToString(); }
public string TransformXML(string strXMLURL, string strXSLURL) { //Create a IO Stream System.IO.StringWriter oSW = new System.IO.StringWriter(); try { System.Xml.XmlTextReader oXR = new System.Xml.XmlTextReader(strXMLURL);
System.Xml.Xsl.XslTransform oXSLT = new System.Xml.Xsl.XslTransform(); oXSLT.Load(strXSLURL);
System.Xml.XPath.XPathDocument oXPath = new System.Xml.XPath.XPathDocument(oXR); oXSLT.Transform(oXPath,null,oSW); } catch (System.Exception e) { //Put in custom error handler here... string x = e.ToString(); } return oSW.ToString(); }
//Create an XsltArgumentList. System.Xml.Xsl.XsltArgumentList xslArg = new System.Xml.Xsl.XsltArgumentList(); TimeSpan oTime = DateTime.Now.TimeOfDay; xslArg.AddParam("cur_time", "", oTime.ToString());
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:param name="cur_time"/> <xsl:template match="/">
<xsl:value-of select="$cur_time"/> </xsl:template> </xsl:stylesheet>
Build Your Own ASP.NET Website Using C# & VB.NET