I trying to import an XML file, and send bits and pieces to a custom component.
My XML file is structured like this:
<projects>
<project>
<projName>{Insert title of project here}</projName>
<startDate>{Insert date here}</startDate>
<positions>
<daysOffset>{Insert a number here}</daysOffset>
<numDays>{Insert a number here}</daysOffset>
<role>{Insert role here}</role>
<student>{Insert name here}</student>
</positions>
// There can be an unlimited amount of positions listed
</project>
// There can be an unlimited amount of projects listed
I read in the XML data by using the following command:
<mx:XML id="projectsXML" xmlns="" source="xml/projects.xml" format="e4x" />
After the XML is imported, I try to use a repeater to send the information within each tag to a custom component. My code is below:
<mx:Canvas width="100%" height="95%" x="0" y="80">
<mx:Repeater id="projectRP" dataProvider="{projectsXML}">
<Block:project
oneDay="{usableSize.width/14}"
projectTitle="{projectRP.currentItem.project.projName}"
projectDate="{projectRP.currentItem.project.startDate}"
projectPositions="{projectRP.currentItem.project.positions as Array}"
/>
</mx:Repeater>
</mx:Canvas>
When I save the project, I do not get any errors or warnings. However, when I attempt to output the values in the component, the projectPositions piece comes back as Null.
Anybody have any ideas? I’ve been trying to figure this out for the better part of two days, and I’m completely stumped 🙁
You’re casting
projectRP.currentItem.project.positionsasArraybut it isXMLList. So after casting you havenull.