Assume I have a RESTful web service, which holds information about an object that can be accessed at an url like http://example.com/myobject. I would like to be able to retrieve this information in two formats: firstly, the XML-formatted plain data, and secondly, as a full HTML page, which may also include a javascript interface to change the object and PUT it back with AJAX.
What is the canonical way to achieve this? Should I publish my object at two different urls like http://example.com/myobject?format=xml and ...format=html? (Are there better ways than using a query string to distinguish the URLS here?) Or is it sensible to send something like multipart MIME data and can I rely on browsers being able to extract the HTML part? Or is there some HTTP header field in the request I could use?
(With PUT or POST requests sent in different formats, it is much easier as the server can check the format and parse it accordingly.)