![]() |
![]() |
||||||
|
|||||||
| Tags: |
![]() |
|
|||
|
I'm getting the Soap response from a weather webservice. I can see the XML
string in the Soap body using Alert.show. But when I tried to retrieve the data inside the XML, I got nothing. [Bindable] private var xmlResult:XML; private function getResult(event:ResultEvent):void { xmlResult = new XML(event.result); Alert.show(xmlResult.toXMLString()); //This line shows the soap body. Please see below. var xml_list:XMLList = xmlResult.GetCityWeatherByZIPResult; Alert.show(xml_list.toXMLString()); //This line shows nothing. } I also tried {xmlResult..City}, but it returns nothing. This is what I see in the first Alert window: <GetCityWeatherByZIPResponse xmlns="http://ws.cdyne.com/WeatherWS/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelo pe/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <GetCityWeatherByZIPResult> <Success>true</Success> <ResponseText>City Found</ResponseText> <State>TX</State> <City>Huston</City> <WeatherStationCity>Huston</WeatherStationCity> <WeatherID>10</WeatherID> <Description>Mostly Sunny</Description> <Temperature>73</Temperature> <RelativeHumidity>42</RelativeHumidity> <Wind>SW9</Wind> <Pressure>29.78F</Pressure> <Visibility/> <WindChill>0</WindChill> <Remarks/> </GetCityWeatherByZIPResult> </GetCityWeatherByZIPResponse> |
| Sponsored Links |
|
|||
|
"JZBAO" <webforumsuser@macromedia.com> wrote in message news:gh9qro$qv3$1@forums.macromedia.com... > I'm getting the Soap response from a weather webservice. I can see the XML > string in the > Soap body using Alert.show. But when I tried to retrieve the data inside > the > XML, I got nothing. > > [Bindable] private var xmlResult:XML; > private function getResult(event:ResultEvent):void { > xmlResult = new XML(event.result); > Alert.show(xmlResult.toXMLString()); //This line shows the > soap body. Please see below. > var xml_list:XMLList = xmlResult.GetCityWeatherByZIPResult; > Alert.show(xml_list.toXMLString()); //This line shows > nothing. > } http://www.magnoliamultimedia.com/fl...s_Flex_FAQ.pdf Q14 |
|
|||
|
I changed my code a little bit:
[Bindable] private var xmlResult:XML; private function getResult(event:ResultEvent):void { xmlResult = new XML(event.result); Alert.show(xmlResult.toXMLString()); var xml:XML = xmlResult.GetCityWeatherByZIPResult[0]; Alert.show(xml.toXMLString()); //This line throws null point exception. } The Debugger shows xml is null. Why the dot notation is not working here. Amy, I tried your suggestion in FAQ, but it does not help. |
|
|||
|
I hard coded
[Bindable] private var xmlResult:XML= <GetCityWeatherByZIPResponse xmlns="http://ws.cdyne.com/WeatherWS/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelo pe/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <GetCityWeatherByZIPResult> <Success>true</Success> <ResponseText>City Found</ResponseText> <State>TX</State> <City>Houston</City> <WeatherStationCity>Houston</WeatherStationCity> <WeatherID>10</WeatherID> <Description>Mostly Sunny</Description> <Temperature>73</Temperature> <RelativeHumidity>42</RelativeHumidity> <Wind>SW9</Wind> <Pressure>29.78F</Pressure> <Visibility/> <WindChill>0</WindChill> <Remarks/> </GetCityWeatherByZIPResult> </GetCityWeatherByZIPResponse>; I found it is because e4x can not correctly parse the first line: <GetCityWeatherByZIPResponse xmlns="http://ws.cdyne.com/WeatherWS/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelo pe/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> Bug or virus in my FB3? |
|
|||
|
"JZBAO" <webforumsuser@macromedia.com> wrote in message news:gha8po$e45$1@forums.macromedia.com... >I changed my code a little bit: > > [Bindable] private var xmlResult:XML; > private function getResult(event:ResultEvent):void { > xmlResult = new XML(event.result); > Alert.show(xmlResult.toXMLString()); > var xml:XML = xmlResult.GetCityWeatherByZIPResult[0]; > Alert.show(xml.toXMLString()); //This line throws null point exception. > } > > The Debugger shows xml is null. > Why the dot notation is not working here. > > Amy, I tried your suggestion in FAQ, but it does not help. Clearly not, since you are _still_ trying to reference the root node (which is already the same thing as xmlResult). Try reading it again for comprehension. HTH; Amy |
|
|||
|
"JZBAO" <webforumsuser@macromedia.com> wrote in message news:ghblih$8up$1@forums.macromedia.com... >I tried both > > var xml:XML=xmlResult.City and xmlResult..City > > Neither of them worked. Both gave xml = null in Debugger. Try this: http://dispatchevent.org/roger/using...ur-namespaces/ HTH; Amy |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise