首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >httpService和XMLListCollection

httpService和XMLListCollection
EN

Stack Overflow用户
提问于 2013-01-02 01:29:03
回答 1查看 651关注 0票数 0

我的项目有一个问题,我试图用我从php文件中得到的xml数据来填充列表。我用httpservice调用php文件,这个文件返回xml数据。现在似乎有一个问题,但我没有任何错误。我只是在调试之后知道我的XMLListCollection仍然是空的。

这是我的代码:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" 
                 xmlns:components="components.*"
                 creationComplete="httpService.send()">

    <s:layout>
        <s:VerticalLayout paddingTop="20" gap="20" 
                          horizontalAlign="center" />
    </s:layout>
    <fx:Script>
        <![CDATA[
            import mx.rpc.events.ResultEvent;
            import mx.collections.ArrayCollection; 
            import mx.collections.XMLListCollection; 

            import mx.rpc.events.FaultEvent;
            import mx.controls.Alert;
            private var alert:Alert;

            private function httpService_fault(evt:FaultEvent):void {
                var title:String = evt.type + " (" + evt.fault.faultCode + ")";
                var text:String = evt.fault.faultString;
                alert = Alert.show(text, title);
                Bezoekers.removeAll();
            }

            private function httpService_result(evt:ResultEvent):void {
                var xmlList:XMLList = XML(evt.result).bezoekers.bezoeker;
                Bezoekers = new XMLListCollection(xmlList);

            }






        ]]>
    </fx:Script>
    <fx:Declarations>
        <s:HTTPService id="httpService"
                       url="http://localhost/projectnieuw/src/data/bezoekersList.php"
                       resultFormat="e4x"
                       fault="httpService_fault(event);"
                       result="httpService_result(event)" />
        <!--<fx:Model id="lijstAlleLeden" source="httpAlleLeden" />-->
        <!--<s:ArrayCollection id="acBezoekers" source="{Bezoekers}"/>-->
        <s:XMLListCollection id="Bezoekers"/>
    </fx:Declarations>





    <components:Heading/>
    <s:HGroup gap="50">

        <components:BezoekersList bezoekerList="{Bezoekers}" />
        <components:ReservationForm/>

    </s:HGroup>

</s:Application>

我好像不明白怎么回事。

提前感谢

比利时的问候

EN

回答 1

Stack Overflow用户

发布于 2013-01-02 05:09:19

您的XMLListCollection仍然是空的,意味着Bezoekers = new XMLListCollection(xmlList);给它空。因此,首先,尝试跟踪服务器端的结果并不为空。要测试服务器端的响应,有一个技巧是,在Web浏览器中打开HTTPService的URL并在Web浏览器中获取XML数据。如果获得成功,那么尝试resultFormat="xml"而不是resultFormat="e4x",并阅读HTTPService结果类型的文档化来了解如何使用它。它还为XML提供了一些基于案例的解决方案。

希望这能帮你..。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14115940

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档