views:

140

answers:

2

In the following scenario, you have a business object called Employee that contains all information about the Employee. The object exists in xml form as well as normal .Net object.

If would like to know which of the following methods are faster:

Using xslt stylesheet to transform Employee's xml to html

or

Using something like a html resource file and .NET String.Replace to replace keywords in the resource file with their respective Employee object properties?

+1  A: 

Without doubt, using XSLT to transform your XML into HTML; besides, maintenance will be a lot more easier.

EDIT: More context:

If you have a small HTML, that won't be a problem; but, as your HTML grows, it could be a maintenance nightmare.

Consider, for instance, filling a <table> with your custom object data; building header can be easy, but adding a <tr> for every item collection adds more complexity.

You also have another options: if you're developing a ASP.NET application, you could develop you template as a webpage, execute it from your code and grab your HTML. If can offer you possibility to work with WYSIWYG editor and speed up your development.

Rubens Farias
How does this compare with something like String.Format?
BK
please, check my edited answer for more info
Rubens Farias
Thx for the reply
BK
A: 

I would do this by data binding to a repeater/datagrid in ASP.Net, if at all possible. XSLT is good, but can be unwieldy to maintain imo.

noocyte