views:

11

answers:

1

Judging from the lack of info around, I'm guessing the following question maybe a little "off piste" as they say..

I am trying to find an XML based javascript (pref. JQuery based) templating engine..

A little like say how Ext.JS (Sencha) do things, or SPRY datasets. Something lite..

Obviously there are lots of JSON based ones, and for good reason I know, although I have a requirement that has to use XML.

I have been using John Resig's micro-templating engine for JSON data, and really want something similar for XML based data?

Any ideas? or futile?

A: 

Okay.. of course XSL templates is probably the obvious thing I was overlooking.. just wanted something as straight forward as JQuery's XML manipulation, but applied to a HTML template.

Settled on www.dhtmlx.com and their AJAX function which does client side XSLT. All seems to work very nicely. A snippet is shown below for anyone who is interested:

Javascript:

dhtmlxAjax.get('/PageTemplates/membernotifications_template.xsl', function (xslLoader) {
        var xmlLoader = dhtmlxAjax.getSync('/ajaxget/getmembernotifications.ashx');
        $('#notifications').html(xmlLoader.doXSLTransToString(xslLoader.xmlDoc.responseXML));
    });

You will need the DHX javascript library of course.. the link is above.

As you can see, we reference the .XSL template and then the actual data source, in my case from a .ashx page which just writes out the XML.

We then, using JQuery (however you could refer to a DOM item directly of course), bind the XSL and XML to output into (in my case) a DIV with ID=notifications.

David S