apache flex - httpService and XMLListCollection



我有一个问题与我的项目,我试图填补我的xml数据列表,我得到了一个php文件。我用httpservice调用php文件,该文件返回xml数据。现在看起来好像有问题,但是我没有得到任何错误。我只知道调试后,我的XMLListCollection仍然为空。

下面是我的代码:
<?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>

我好像不明白哪里不对。

Thanks in advance

来自比利时的问候

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

最新更新