title: Generating feed items that won't nest Divs
body: <p>I'm working on this project at helpspread.com. Everything is almost completed, now I need to generate feed on the homepage for logged in users, so they can get live update of an item when it is posted.
  I save the id of the last item they saw and use it to query database for items of ids greater than the saved id, since the ids are auto incremented in the MySQL database. After some few seconds, I do the same and write content to the page.</p>
  <p>The page that does this interval query is an iframe, and writes to the parent frame based on the id of the div.</p>
  <p>This would replace the content of the div if I don't dynamically change it's id after each query. So I came up with the idea of generating div id from the id of the last item seen from database</p>
  <p>But the next problem is that they are nested. An example is this:</p>
  <p>I have a page with</p>
  <pre><code>&lt;div id='new-feed-1367862865'&gt;new item goes here&lt;/div&gt;
  </code></pre>
  <p>I have an iframe with this</p>
  <pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
  var output_feed=&quot;&lt;div id='new-feed-1367862872'&gt;next new item will come here&lt;/div&gt;New&quot;; 
  parent.document.getElementById('new-feed-1367862865').innerHTML=output_feed;
  &lt;/script&gt;
  </code></pre>
  <p>At the end, I'd get something like this: Nested divs</p>
  
  <pre><code>&lt;div id=&quot;new-feed-1367864332&quot;&gt;&lt;div id=&quot;new-feed-1367864461&quot;&gt;&lt;div id=&quot;new-feed-1367864581&quot;&gt;&lt;div id=&quot;new-feed-1367864701&quot;&gt;&lt;div id=&quot;new-feed-1367864821&quot;&gt;&lt;div id=&quot;new-feed-1367864942&quot;&gt;&lt;div id=&quot;new-feed-1367865062&quot;&gt;&lt;div id=&quot;new-feed-1367865182&quot;&gt;&lt;div id=&quot;new-feed-1367865302&quot;&gt;&lt;div id=&quot;new-feed-1367865422&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
  </code></pre>
  <p>This doesn't cause problems on viewing, but is there a better way to do this, that may just append data to a particular div, and not replace its content.</p>