Hmmm, what a great idea. Not sure what I was thinking. I will go that route. :)
On Apr 7, 5:05 pm, James <james.gp....@gmail.com> wrote: > Why not just keep what you have and add an additional conditional > check to see whether the node has an ID attribute or not? If not, > ignore the node. > > On Apr 7, 1:59 pm, Nic Hubbard <nnhubb...@gmail.com> wrote: > > > I am grabbing some XML from our server, then writing that out with > > <li> tags in the browser, all using the jquery .ajax() function. > > > By design, our server wraps items with a parent of the same name, > > like: > > > <test> > > <test id="1">test 1</test> > > <test id="2">test 2</test> > > </test> > > > Because my function checks for each test tag, it finds the first > > parent, but returns undefined, since it does not have any attributes. > > Is it possible to ignore this first result, and start with the second > > item, which will correctly have attributes? > > > success: function(xml) { > > $(xml).find('testt').each(function() { > > var id_text = $(this).attr('id') > > var id_name = $(this).attr('name') > > $('<li></li>').html('id_code + ' - ' + > > id_text).appendTo('#test'); > > }); > > }