Replacing variable text in XSLT file
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开发者_Go百科 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.
Of course, you can, in C#:
String replaced;
using(var fs = new StreamReader(fileName)) {
String xml = fs.ReadToEnd();
replaced = xml.Replace("search?", "Search.aspx?");
}
using(var output = new StreamWriter(fileOutput)) {
output.Write(replaced);
}
精彩评论