public partial class HS_SearchResult : System.Web.UI.Page { ConnectionLogin cl = new ConnectionLogin(); // user define class public string SearchResults = string.Empty; protected void Page_Load(object sender, EventArgs e) { DataSet ds = new DataSet("Category"); ds = cl.dataset("select * from tblItem where cat_id = "+Request.QueryString["q"]); // get xml file from data set string XMLfile = ds.GetXml(); SearchResults = GetHtml(Server.MapPath("~/HS/XSLTFILES/Searchcat.xslt"), XMLfile); } public static string GetHtml(string xsltpath,string xmlfile) { MemoryStream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(xmlfile)); XPathDocument xx = new XPathDocument(stream); StringWriter wr = new StringWriter(); XslCompiledTransform xc = new XslCompiledTransform(); xc.Load(xsltpath); xc.Transform(xx, null, wr); return wr.ToString(); } }
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"> <xsl:output method="html" indent="yes"/> <xsl:template match="/"> <html> <head> <title></title> </head> <body style="color:black;"> <h1>Your Result Here</h1> <table id="searchresult"> <xsl:for-each select="Category/cat_id"> // i think the mistake is here can any body tell me what shoult be the right directory in select attribute <tr> <td class="labledata"> Name:</td> <td> <xsl:value-of select="item_name"/> </td> </tr> <tr> <td class="labledata">Address:</td> <td> <xsl:value-of select="item_owner"/> </td> </tr> </xsl:for-each> </table> rohihumai </body> </html> </xsl:template> </xsl:stylesheet>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)