I have an object that contains a listing of unique column names:
["heading", "startDate", "finishDate"]
I am returning an XML data set that looks like similar to this this:
<z:row ows_heading='Header' ows_startDate='1/1/2016' ows_finishDate='1/11/2016' ows_Description='Ignore me'/>
<z:row ows_heading='Header' ows_startDate='2/3/2016' ows_finishDate='2/12/2016' ows_Description='Ignore me'/>
How do I loop through the unique column name object to get the column name, append "ows_" to it and then find the resulting value and add it back to the object so that the end result is something like:
["heading": "Header", "startDate": "1/1/2016", "finishDate": "1/11/2016"]
EDIT: Current code block:
var a=[];var obj={};
$(r).find("[nodeName=z:row]").each(function()
{
$.each(uniqHeaderVals, function( key, value ) {
var thisVal = $(this).attr("ows_"+value);
obj.value = thisVal;
});
a.push(obj);
});
console.log(a);