I have following code in a file with extension .tpl (Smarty template)
{foreach from=$randomSites value=site}
<a href="{$site|objurl:'siteDetails'}" title="{$site.siteTitle}" >
<img alt="{$site.siteTitle}" src="{$site.imageSrc}" class="random_image" />
</a>
{/foreach}
It produce a list of sites with thumbnails..
Is it possible convert this code in a XML file with a simplexml class or similar?
I must convert in PHP code first?
You have two choices. First, you can use a Smarty template to create your XML, something like this:
Second, as you suggest, you can build your XML tree in a library like SimpleXML or DOM in memory, then serialize it to disk. The benefit is that the library will prevent any XML markup errors; the disadvantage is that it will be harder for a non-XML-specialist to picture what the output will look like based on the library calls.