[edit]
My bad, I made an assumption and you know what that gets you.
Joomla! 1.6->2.5 you can create an alternate output format for an existing view by:
- calling the view with a format parameter attached e.g.
&format=json
- creating a matching view class file e.g.
view.json.php
that can sit alongside the standard view.html.php
file for you view.
The view.yourformat.php
file can use your existing controllers and template files in the normal fashion.
Don't forget to add either &tmpl=component
or &tmpl=raw
to your query string so modules etc don't load as well.
tmpl=raw
won't load the html body surrounds or template, only the main component.
[/edit]
From Joomla! 1.6 onward (including 2.5) there is built in support for controller formats ie. you create a controller for the output format you want.
Normally a controller would be named for each view:
/components/mycomp/controllers/myview.php
A XML version of the controller would be name:
/components/mycomp/controllers/myview.xml.php
A JSON version would be:
/components/mycomp/controllers/myview.json.php
To call a particular format version of a controller you simply add &format=theformatyouwant
to the URL parameters, so in your case &format=xml
This is discussed in this document from 1.6 days - I used it as a basis for several of our components that have JSON and ics requirements.