How to I add unique id and title to nivo-slider captions using jQuery?

How to I add unique id and title to nivo-slider captions using jQuery?

I've started code to pull information from my xml files and spit them out into a format like nivo-slider. 

Only in order for nivo-sliders html captions to work you need to have unique ids for the caption div and for the img title attribute. I know that generally you don't use unique ids, but this is how nivo-slider works. 

I need help coming up with a way to create unique ids and titles such as: "htmlcaption1", "htmlcaption2", etc...

Here's the code:
  1. $(document).ready(function()
  2.    {
  3.     $.get('/design/designsystems/unitedway/unitedway.xml', function(d){
  4.         $(d).find('pic').each(function(){

  5.             var title = $(this).find('title').text();
  6.      var image = $(this).find('image').text();
  7.      var caption = $(this).find('caption').text();
  8.      var thumbnail = $(this).find('thumbnail').text();
  9.      var link = $(this).find('link').text();
  10.      var linkdes = $(this).find('linkdes').text();
  11.             
  12.      var html = '<a href="' + link + '"' + 'rel="prettyPhoto"' + 'title="' + linkdes + '"' + '>' + '<img src="' + image + '"' + 'title="#htmlcaption"' + '/>' + '</a>';
  13.      var caption = '<div id="htmlcaption" class="nivo-html-caption">' + title + '<br><span class="caption">' + caption + '</span></div>';
  14.             
  15.      $('#slider').append($(html));
  16.     $('#slider').after($(caption));
  17.    
  18.         });
  19.     });
  20. });
Here's a link to the xml:

The xml is formated something like this:
  1. <images>
  2.     <pic>
  3.         <title>Project Title</title>
  4.         <image>/imagetitle1.jpg</image>
  5.         <caption>image caption</caption>
  6. <thumbnail>/thumbs/imagetitle1.jpg</thumbnail>
  7. <link>/imagetitle1.jpg</link>
  8. <linkdes>image caption</linkdes>
  9.     </pic>
  10.     <pic>
  11.         <title>Project Title</title>
  12.         <image>/imagetitle2.jpg</image>
  13.         <caption>image caption</caption>
  14. <thumbnail>/thumbs/imagetitle2.jpg</thumbnail>
  15. <link>/imagetitle1.jpg</link>
  16. <linkdes>image caption</linkdes>
  17.     </pic>
  18. </images>
The html is something like this:

  1.   <div id="slider-container">
  2.   <div class="slider-wrapper theme-kristy">
  3.     <div id="slider" class="nivoSlider"></div>
  4. </div>
  5. </div>