httpService和XMLListCollection

编程入门 行业动态 更新时间:2024-10-26 17:30:25
本文介绍了httpService和XMLListCollection的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

这是我的代码:

<?xml version =1.0encoding =utf-8?> 我似乎并没有得到什么错。

预先致谢

来自比利时的问候

解决方案

你的XMLListCollection保持为null 表示 Bezoekers = new XMLListCollection(xmlList); 给它null。所以首先尝试跟踪那个结果不是从服务器端的空。要测试服务器端的响应,你有一个窍门是,在Web浏览器中打开你的HTTPService的URL,并在Web浏览器中获取XML数据。如果获得成功,则尝试 resultFormat =xml而不是 resultFormat =e4x并读取 HTTPService结果文件类型,以了解如何使用它。它也有一些针对XML的案件到案例的解决方案。

这可以帮助你...

I have a problem with my project where I try to fill a list with my xml data that I get out of an php file. I call the php file with a httpservice and this file returns xml data. Now it seems that there is a problem, but I don't get any error. I just know after debugging that my XMLListCollection remains null.

Here is my code :

<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="ns.adobe/mxml/2009" xmlns:s="library://ns.adobe/flex/spark" xmlns:mx="library://ns.adobe/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="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>

I don't seem to get what's wrong.

Thanks in advance

Greetings from Belgium

解决方案

your XMLListCollection remains null means Bezoekers = new XMLListCollection(xmlList); gives to it null. so first of all try to trace that result was not null from server-side. To test server-side response, you have one trick is that, open your HTTPService's URL in web-browser and get XML data in Web-browser. if get success then try resultFormat="xml" instead of resultFormat="e4x" and read documentation of HTTPService's result Type to know how to use it. it has also some case-to-case basis solution for XML.

May this will help you...

更多推荐

httpService和XMLListCollection

本文发布于:2023-11-25 04:17:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628291.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:httpService   XMLListCollection

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!