[JS] Problem defining an object while grabbing info from xmlElements
Hi,
Here is some piece of code I wrote in order to create an object. This object is expected to contain a property whise name is based on the value of
the "airport_title" tag. I set the value to the page the xmlElement is on.
The XML STructure in Indesign is like this :


When I run this code, I can see that the properties have been defined. However, if I try to access them, it returns undefined.
obj["TXFULLSHEARTexasX09"]//undefined
More confusing is that I place a dummy "toto" property which is available.
obj["toto"] //28500 as expected.
I am out of ideas here. Any hint ?
TIA Loic
PS: I checked the my variable airport_title variableconbstructor and that's a string.

Here is the code
function makePageIndexFromAirportTemplate(aTemplate){
//var tempDoc=app.open(aTemplate);
var tempDoc=app.activeDocument;
var airportPages = {};
try{
var airports_catalogue = tempDoc.xmlElements[0];
var airport=airports_catalogue.xmlElements;
var airportLength = airport.length;
for(var i=0; i<airportLength; i++){
var theAirport = airport;
//alert(airport.markupTag.name);
var bloc_airport = theAirport.xmlElements[0];
var airportTitle = bloc_airport.contents;
airportTitle = airportTitle.replace(/[ \-,;()]/g,"");
// alert(bloc_airport.storyOffset.parentTextFrames[0].parentPage.name);
var pg = bloc_airport.storyOffset.parentTextFrames[0].parentPage.name;
//airportPages["\""+airportTitle+"\""]=Number(pg);
//var airportTitle = "\""+airportTitle+"\"";
airportPages[airportTitle]=pg;
}
//tempDoc.close();
airportPages["toto"]="28500";
return airportPages;
}
catch(e){
alert(e);
}
//tempDoc.close();
return false;
}
var obj = makePageIndexFromAirportTemplate();
obj["toto"];