Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8577307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:07:47+00:00 2026-06-11T20:07:47+00:00

I want to get xml data from free.worldweatheronline.com I tried in flollowing way:- <fx:Script>

  • 0

I want to get xml data from free.worldweatheronline.com
I tried in flollowing way:-

<fx:Script>
    <![CDATA[
        import mx.rpc.events.FaultEvent;
        import mx.rpc.events.ResultEvent;
        private var main_xml_url:String = "http://free.worldweatheronline.com/feed/weather.ashx?q="+cityName.text.toString()+"&format=xml&num_of_days=2&key=my_api_key"; // there I put my api key not showing here//


        protected function weatherService_resultHandler(event:ResultEvent):void
        {
            // TODO Auto-generated method stub
            var result_weather_data:Object = event.result;
            cityNameData.text = data.request.query;

        }

        protected function weatherService_faultHandler(event:FaultEvent):void
        {
            // TODO Auto-generated method stub
            cityNameData.text = event.message.toString();
        }

    ]]>
</fx:Script>

<fx:Declarations>       
    <s:HTTPService id="weatherService"
                   url="main_xml_url"
                   resultFormat="object"
                   result="weatherService_resultHandler(event)"
                   fault="weatherService_faultHandler(event)"/>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:TextInput id="cityName" text="Hyderabad" x="10" y="10" width="219" fontWeight="bold" prompt="Enter city Name"/>

<s:Label id="cityNameData" x="108" y="109" width="202" fontSize="20" fontWeight="bold"/>    

But there comes an error saying that:
Cannot access a property or method of a null object reference.
at private var main_xml_url:String

please do a favour for by solving it Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:07:48+00:00Added an answer on June 11, 2026 at 8:07 pm

    The code above means that you are trying to retrieve and assign the value of cityName.text.toString() at object initialization time.

    The display object cityName which is a TextInput will not be added to the display at the time of assignment. Hence, you are getting the NPE.

    You can correct this as follows:

    <fx:Declarations>
        <s:HTTPService id="weatherService"
            url="{BASE_URL}"
            resultFormat="object"
            result="weatherService_resultHandler(event)"
            fault="weatherService_faultHandler(event)">
            <s:request xmlns="">
                <q>{cityName.text.toString()}</q>
                <format>{FORMAT}</format>
                <num_of_days>{NUMBER_OF_DAYS}</num_of_days>
                <key>{API_KEY}</key>
            </s:request>
        </s:HTTPService>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    
    <fx:Script>
        <![CDATA[
            import mx.rpc.events.FaultEvent;
            import mx.rpc.events.ResultEvent;
    
            private static const BASE_URL:String="http://free.worldweatheronline.com/feed/weather.ashx"
            private static const API_KEY:String="your API key here"
            private static const NUMBER_OF_DAYS:uint=2;
            private static const FORMAT:String="xml";
    
            protected function weatherService_resultHandler(event:ResultEvent):void
            {
                // TODO Auto-generated method stub
                var result_weather_data:Object=event.result;
                cityNameData.text=result_weather_data.request.query;
    
            }
    
            protected function weatherService_faultHandler(event:FaultEvent):void
            {
                // TODO Auto-generated method stub
                cityNameData.text=event.message.toString();
            }
        ]]>
    </fx:Script>
    <s:layout>
        <s:VerticalLayout/>
    </s:layout>
    <s:TextInput id="cityName"
        width="219"
        text="Hyderabad"
        x="10"
        y="10"
        fontWeight="bold"
        prompt="Enter city Name"/>
    
    <s:Label id="cityNameData"
        width="202"
        x="108"
        y="109"
        fontSize="20"
        fontWeight="bold"/>
    
    <s:Button label="Send" click="{weatherService.send()}"/>
    

    Also, you forgot to call the send() on the weatherService object.
    This means that your webservice call would not have been triggered anyway.

    For more info on this matter, check out the LiveDocs

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one problem , I want to get some data from XML file
i get my pagedata from an xml and i want this data to be
i want to get data from xml parser ? how can i get from
i want to get data from xml file and display it into html. Which
I'm getting an xml file and want to get data from it. The source
I want to get xml data from google server using it's API. so, i
I want to get data from XML API output from Vimeo. In Vimeo if
What I want: get a xml from the AppData to use What I code
I want to get the CreateDate value from xml file the xml file is
I am trying to select three values from xml document. I want to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.