I am using Google Search Application for our website search feature. I am getting the search results in an XML format and i have included the default XSLT file in my application for formatting of the search results. I want to display the XMl results in our
search page instead of directing to the search page on the Google Mini Search Server. I am able to display the results in the search page. However, when I try to move to the next page for the search, the links point to the search page on the Google Mini Search
server. I need to update the default XSLT file as it contains a couple of variables which point to the search page on the server.
All i want to is replace the search? with Search.aspx? in the XSLT file. I dont want to do it in XSLT, as XSLT file may change and dont want to update it with search template. Is there a way I can do it with C#/ASP.net in code behind. If it were an XMl file,
we could read it in a char array and then create a string out of it and then use Replace method to update the values. Can something similar be done with XSLT file too or any other solution.
//Replace the search keyword in XSLT file to Search.aspx
if (!(Page.IsPostBack) && (File.Exists(styleSheet)))
{
String replaced;
using (var fs = new StreamReader(styleSheet))
{
String xml = fs.ReadToEnd();
replaced = xml.Replace("search?", "Search.aspx?");
}
using (var output = new StreamWriter(styleSheet))
{
output.Write(replaced);
}
}
Member
1 Points
25 Posts
Replacing variable text in XSLT file
Jun 28, 2011 02:06 PM|seemashah|LINK
I am using Google Search Application for our website search feature. I am getting the search results in an XML format and i have included the default XSLT file in my application for formatting of the search results. I want to display the XMl results in our search page instead of directing to the search page on the Google Mini Search Server. I am able to display the results in the search page. However, when I try to move to the next page for the search, the links point to the search page on the Google Mini Search server. I need to update the default XSLT file as it contains a couple of variables which point to the search page on the server.
All i want to is replace the search? with Search.aspx? in the XSLT file. I dont want to do it in XSLT, as XSLT file may change and dont want to update it with search template. Is there a way I can do it with C#/ASP.net in code behind. If it were an XMl file, we could read it in a char array and then create a string out of it and then use Replace method to update the values. Can something similar be done with XSLT file too or any other solution.
Thanks.
Member
1 Points
25 Posts
Re: Replacing variable text in XSLT file
Jun 28, 2011 04:27 PM|seemashah|LINK