I'm currently maintainging some DS/JS code in Demandware and I just found that :
var XmlReponse : XML = new XML(result.object.text);
status = XmlReponse.@["STATUS"];
What does this unusual "@[...]" syntax do ?
It could have something to do with ECMA-357 specification (aka "E4X"), but I'm not sure : in the DW docs (needs credentials), it is said :
"You can read values from an XML object the same way you would from standard ECMAScript objects"
var quantity = order.item(0).@quantity;
var singleItem = order.item.(@quantity == 1);
That seems to explain the @
but let me skeptical about the following square brackets, maybe some kind of dynamic property ?
Thanks :)
From reading the ex4 manual it seems to read a property of an xml element. I don't see that reading the indexer would be any different
Your mentioned code would then read the attribute STATUS
on the xmlresponse
The code on the linked ex4 manual status:
E4X allows you to access the attributes of a particular element with the .@ operator. The most basic case would look something like.
var element = <foo bar="1"/>
element.@bar = 2;