Read through this post to help speed up DOM inserts: http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly
On Mar 23, 3:46 pm, Martin Tiršel <j...@blackpage.eu> wrote: > Hello, > > I get XML answer from server with ~5k lines and I need to parse this data > into the table and display in HTML. I wrote a script to do this job, but > it takes too much time to complete (~35 seconds in opera), what is not I > want. Is there a way to improve this script? Perhaps there is more > effective way to do this. > > XML looks like: > > <?xml version="1.0" encoding="UTF-8" ?> > <xmldata> > <page> > <name>ebapylibnfwxorjwoeseksnyqumdmxssaduy</name> > <id>5</id> > <url>ojosjkfujggkildmlr</url> > <author> > <id>7</id> > <name>b</name> > </author> > <languages> > <lang>sk</lang> > <lang>cz</lang> > </languages> > </page> > ... 500x similar as above > </xmldata> > > JS: > > ... > var table = '<table > class="pagelist"><thead><tr><th>Name</th><th>Author</th><th>Languages</th><th>Actions</th></tr></thead><tbody>'; > > $(xml).find("page").each(function(i) { > var name = $(this).find("name").text(); > var author = $(this).find("author name").text(); > var languages = new Array(); > $(this).find("languages lang").each(function() { > languages.push($(this).text()); > }); > languages = languages.join(','); > table += '<tr><td class="first">' + name + '</td><td > class="second">' + author + '</td><td class="third">' + languages + > '</td><td class="fourth"> </td></tr>'; > }); > > table += '</tbody></table>'; > > $("#content_window_pages").append(table); > ... > > XML structure can be changed if it helps to speed up the script. > > Thanks for any suggestions, > Martin