public class XmlExample extends Sprite {
public function XmlExample() {
var emp:XML =
<employees>
<employee ssn="123-123-1234">
<name first="John" last="Doe"/>
<address>
<street>11 Main St.</street>
<city>San Francisco</city>
<state>CA</state>
<zip>98765</zip>
</address>
</employee>
<employee ssn="789-789-7890">
<name first="Mary" last="Roe"/>
<address>
<street>99 Broad St.</street>
<city>Newton</city>
<state>MA</state>
<zip>01234</zip>
</address>
</employee>
</employees>;
I saw this example on flex documentation. To access the element, I could do:
emp.employee[0].address.zip
But I don’t understand why not
emp.employees.employee[0].address.zip
Why they design to skip the top element “employees”? From my understanding, if it’s a arraycollection, then I have to add an extra “employees”.