![]() |
![]() |
||||||
|
|||||||
| Tags: |
![]() |
|
|||
|
Hi,
I am using Yahoo Local Search Service which returns the XML response. I want to retrieve data from the XML that I received. I stuck at this point and unable to retrieve the response in to datagrid. Does the namespaces in XML matter while retrieving data? The response XML is as follows <ResultSet xsi:schemaLocation="urn:yahoo:lcl http://api.local.yahoo.com/LocalSearchService/V3/L ocalSearchResponse.xsd" totalResultsAvailable="224" totalResultsReturned="1" firstResultPosition="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:yahoo:lcl"> <ResultSetMapUrl>http://maps.yahoo.com/broadband/?q1=...A+95112&tt =starbucks&tp=1</ResultSetMapUrl> <Result id="21590724"> <Title>Starbucks</Title> <Address>145 W Santa Clara St</Address> <City>San Jose</City> <State>CA</State> <Phone>(408) 288-8803</Phone> <Latitude>37.335236</Latitude> <Longitude>-121.892765</Longitude> <Rating> <AverageRating>4</AverageRating> <TotalRatings>3</TotalRatings> <TotalReviews>2</TotalReviews> <LastReviewDate>1198029377</LastReviewDate> <LastReviewIntro>My previous review had incorrect data. That was not true, I am sorry, I didn't know. As far as food and drink goes, Starbucks is pretty good.</LastReviewIntro> </Rating> <Distance>0.96</Distance> <Url>http://local.yahoo.com/info-21590724-starbucks-san-jose</Url> <ClickUrl>http://local.yahoo.com/info-21590724-starbucks-san-jose</ClickUrl> <MapUrl>http://maps.yahoo.com/maps_result?q1...San+Jose+CA&am p;gid1=21590724</MapUrl> <BusinessUrl>http://www.starbucks.com/</BusinessUr l> <BusinessClickUrl>http://www.starbucks.com/</Busin essClickUrl> <Categories> <Category id="96926219">Cafes</Category> <Category id="96926236">Restaurants</Category> <Category id="96926169">Coffee Houses</Category> </Categories> </Result> </ResultSet> The code that I am writing to get Title and Address is as follows. <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" backgroundAlpha="0" backgroundColor="#FFFFFF"> <mx:HTTPService id="weatherService" url="http://local.yahooapis.com/LocalSearchService/ V3/localSearch" resultFormat="e4x" result="resultHandler(event);"/> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.rpc.events.ResultEvent; [Bindable] private var myResult:XML ; private var temp:XMLNode; private var list:ArrayCollection; public function requestWeather():void { weatherService.cancel(); var params:Object = new Object(); params.appid = "YahooDemo"; params.query = "starbucks"; params.zip = "95112"; params.results = "1" weatherService.send(params); } public function resultHandler(event:ResultEvent):void { myResult = XML( event.result); temp = myResult.Result; list = ArrayCollection(event.result); } ]]> </mx:Script> <mx:Form width="400"> <mx:FormItem label="Get Local Data"> <mx:Button label="Get Data" click="requestWeather();"/> </mx:FormItem> <mx:FormItem label="Address"> <mx:Text text="{myResult.Result.Address}"/> </mx:FormItem> <mx:FormItem label="Title"> <mx:Text text="{myResult.Result.Title}"/> </mx:FormItem> </mx:Form> <mx ataGriddataProvider="{myResult.Result}" x="80" y="141" width="262" height="92" id="shippingOptionsList" editable="false" enabled="true"> <mx:columns> <mx ataGridColumn headerText="Title" dataField="Title" /><mx ataGridColumn headerText="Address" dataField="Address" /></mx:columns> </mx ataGrid><mx:Label text="Response as it is"/> <mx:TextArea id="resultFld" text="{myResult}" width="400" height="152"/> </mx:Application> Can somebody help me to find where I am going wrong? Thank you -Pranay |
| Sponsored Links |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise