Parsing XML and prepend HTML every 3 elements
Perhaps using a template system can help you, check http://handlebarsjs.com/ you can integrate with jquery and reuse partial html code as a templates

&lt;script id="entry-template" type="text/x-handlebars-template"&gt;
&lt;div class="entry"&gt;
  &lt;h1&gt;{{title}}&lt;/h1&gt;
  &lt;div class="body"&gt;
    {{{body}}}
  &lt;/div&gt;
&lt;/div&gt;
&lt;/script&gt;

&lt;script type="text/javascript" charset="utf-8"&gt;
// Compiling template to generate function
var source   = $("#entry-template").html();
var template = Handlebars.compile(source);

//  When you receive your data content var just call this:
var context = {title: "My New Post", body: "This is my first post!"};
// in your case maybe it is:
// var context =    { img_src: $(data).attr("src"), href=$(data).attr("href"), title1: $(data).attr("title1"), client : $(data).attr("client") };
var html    = template(context);

&lt;/script&gt;