Hello,
First of all Im parsing xml from an ajax function
Im trying to create an object using the $.each function from the returned xml with any name and value of unknown attributes.
The xml is parsing and all that, no problems there. I cant create a set of objects from my $.each function. So far Im just getting a single string array.
Im trying to substitute from a fixed set of attributes to a variable set of attrbutes:
- this.aSuggestions.push(
- { 'id':results[i].getAttribute('id'),
- 'value':results[i].childNodes[0].nodeValue,
- 'info':results[i].getAttribute('info'),
- 'ipname':results[i].getAttribute('ipname') ,
- 'ipadr1':results[i].getAttribute('ipadr1'),
- 'ipadr2':results[i].getAttribute('ipadr2'),
- 'ipadr3':results[i].getAttribute('ipadr3'),
- 'ipcity':results[i].getAttribute('ipcity'),
- 'ipstat':results[i].getAttribute('ipstat'),
- 'ipzipc':results[i].getAttribute('ipzipc'),
- 'ipprov':results[i].getAttribute('ipprov'),
- 'ipcoun':results[i].getAttribute('ipcoun'),
- 'ipphon':results[i].getAttribute('ipphon'),
- 'ipfaxn':results[i].getAttribute('ipfaxn'),
- 'ipconm':results[i].getAttribute('ipconm'),
- 'ipmail':results[i].getAttribute('ipmail'), } );
- }
With:
- var xtest= [];
- $(xml).find('row').each(function() {
- xtest.push('{');
- $.each(this.attributes, function () {
- var xtestname = ($(this).attr('name'));
- var xtesttext = ($(this).text());
- xtest.push(xtestname + ':' + xtesttext);
- });
- xtest.push('},');
- });