Flex 3 - 如何从 XML 动态读取数据
我是 Flex 的新手,我想知道如何使用 Flex Builder 3 读取 xml 文件以将其数据提取到图表中。
尽管我已经阅读并完成了一些教程,但我还没有看到它们中的任何一个加载数据动态。例如,我想要一个如下所示的 xml:
<data>
<result month="April-09">
<visitor>
<value>8</value>
<fullname>Brian Roisentul</fullname>
<coid>C01111</coid>
</visitor>
<visitor>
<value>15</value>
<fullname>Visitor 2</fullname>
<coid>C02222</coid>
</visitor>
<visitor>
<value>20</value>
<fullname>Visitor 3</fullname>
<coid>C03333</coid>
</visitor>
</result>
<result month="July-09">
<visitor>
<value>15</value>
<fullname>Brian Roisentul</fullname>
<coid>C01111</coid>
</visitor>
<visitor>
<value>6</value>
<fullname>Visitor 2</fullname>
<coid>C02222</coid>
</visitor>
<visitor>
<value>12</value>
<fullname>Visitor 3</fullname>
<coid>C03333</coid>
</visitor>
</result>
<result month="October-09">
<visitor>
<value>10</value>
<fullname>Brian Roisentul</fullname>
<coid>C01111</coid>
</visitor>
<visitor>
<value>14</value>
<fullname>Visitor 2</fullname>
<coid>C02222</coid>
</visitor>
<visitor>
<value>6</value>
<fullname>Visitor 3</fullname>
<coid>C03333</coid>
</visitor>
</result>
</data>
然后循环遍历每个“访问者”xml 项并绘制它们的值,并在鼠标位于其行上方时显示它们的“全名”。
如果您需要一些额外信息,请告诉我。
谢谢,
布莱恩
I'm new at Flex and I wanted to know how to read an xml file to pull its data into a chart, using Flex Builder 3.
Even though I've read and done some tutorials, I haven't seen any of them loading the data dynamically. For example, I'd like to have an xml like the following:
<data>
<result month="April-09">
<visitor>
<value>8</value>
<fullname>Brian Roisentul</fullname>
<coid>C01111</coid>
</visitor>
<visitor>
<value>15</value>
<fullname>Visitor 2</fullname>
<coid>C02222</coid>
</visitor>
<visitor>
<value>20</value>
<fullname>Visitor 3</fullname>
<coid>C03333</coid>
</visitor>
</result>
<result month="July-09">
<visitor>
<value>15</value>
<fullname>Brian Roisentul</fullname>
<coid>C01111</coid>
</visitor>
<visitor>
<value>6</value>
<fullname>Visitor 2</fullname>
<coid>C02222</coid>
</visitor>
<visitor>
<value>12</value>
<fullname>Visitor 3</fullname>
<coid>C03333</coid>
</visitor>
</result>
<result month="October-09">
<visitor>
<value>10</value>
<fullname>Brian Roisentul</fullname>
<coid>C01111</coid>
</visitor>
<visitor>
<value>14</value>
<fullname>Visitor 2</fullname>
<coid>C02222</coid>
</visitor>
<visitor>
<value>6</value>
<fullname>Visitor 3</fullname>
<coid>C03333</coid>
</visitor>
</result>
</data>
and then loop through every "visitor" xml item and draw their values, and display their "fullname" when the mouse is over their line.
If you need some extra info, please let me just know.
Thanks,
Brian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
livedocs 中的折线图示例帮助您开始。他们使用数组集合 - 您可以将其替换为
XMLListCollection
。您可以在示例中使用
visitors
代替expenseAC
。The line chart example in the livedocs would help you to get started. They are using an array collection - you can replace it with an
XMLListCollection
.You can use
visitors
in the place ofexpenseAC
in their example.