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 4116542
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:43:17+00:00 2026-05-20T22:43:17+00:00

in my app when i click a button, i want to show an xml

  • 0

in my app when i click a button, i want to show an xml file which is been stored in a database of an url, how to do this, pls give me an example.

  • 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-05-20T22:43:17+00:00Added an answer on May 20, 2026 at 10:43 pm

    Have a server side script get the data on the server and return it as XML. Then download the page and load it into your application.

    Using this code you can get an xml file from an online database and parse it as a xml Document in Android.

    Document xmlDocument = fromString(downloadPage("http://example.com/data.php");
    

    This is a short script that should download a webpage and return it as a string

    public String downloadPage(String targetUrl)
    {
        BufferedReader in = null;
        try
        {
            // Create a URL for the desired page
            URL url = new URL(targetUrl);
    
            // Read all the text returned by the server
            in = new BufferedReader(new InputStreamReader(url.openStream()));
            String str;
            String output = "";
            while ((str = in.readLine()) != null)
            {
                // str is one line of text; readLine() strips the newline
                // character(s)
                output += "\n";
                output += str;
            }
            return output.substring(1);
        }
        catch (MalformedURLException e)
        {}
        catch (IOException e)
        {}
        finally
        {
            try
            {
                if (in != null) in.close();
            }
            catch (IOException e)
            {
    
            }
        }
        return null;
    }
    

    This is a simple DOM parser to parse a string into a Document object.

    public static Document fromString(String xml)
    {
        if (xml == null)
            throw new NullPointerException("The xml string passed in is null");
    
        // from http://www.rgagnon.com/javadetails/java-0573.html
        try
        {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            InputSource is = new InputSource();
            is.setCharacterStream(new StringReader(xml));
    
            Document doc = db.parse(is);
    
            return doc;
        }
        catch (SAXException e)
        {
            return null;
        }
        catch(Exception e)
        {
            CustomExceptionHandler han = new CustomExceptionHandler();
            han.uncaughtException(Thread.currentThread(), e);
            return null;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in my app when i click a button it gets an xml file from
I'm in the midst of writing a slide show app (click a button, and
I have this code in a button click for ratting this app -(IBAction)_clickbtnratethisApp:(id)sender {
i am Developing app for Blackberry.in button click event i want to hide/invisible verticalFieldManager
I want to click a button, have a text input box show up and
In my Swing app, users can click a button to open a dialog panel
Hello StackOverflow'ers, I have a (flex) app that, on the click of a button,
I need a function that a user can just click a flash app button
I want to make a right click menu for my winforms app. It will
I made a soundboard app where when I click a button, it plays a

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.