Render HTML via XML ajax

Render HTML via XML ajax

Hello,

i am wondering, what is the best way to render HTML on a page using an ajax request that gets the data as an XML file?

i.e

Say for example you wanted to load the comments on a particular news post, and wanted to pull this data in via ajax, and you server returns an xml with the commens in it, for example:

<comment>
      <name>Joe Bloggs</name>
      <post>Lorem ipsum dolar emet</post>
      <date>12/12/2000</date>
      <profile_id>12</profile_id>
</comment>
<comment>
      <name>John Doe</name>............etc....

and then take that xml file and use it to render a list of comments, with profile pictures (worked out from the `profile_id`). I ask as i can do this easy enough by just making the server return the output as HTML, then placing it inside a container for the comments, but this is slower as the html output would be much bigger in size then the xml output.

I also need the ability to add a callback function so i can make a popup display if there is an error, or run a function that does something after the data is loaded.

Ideal'y id like to load the html template which i would use along side the xml file, via ajax, but this isnt completely neceserry.