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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:42:26+00:00 2026-06-10T14:42:26+00:00

I am currently using a xml that has been downloaded and parsed from there.

  • 0

I am currently using a xml that has been downloaded and parsed from there. I would like to do it directly from the url itself. How can I do that?

I have added the snippet I am using below. Kindly help with a snippet or example.Thank you.

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
File file = new File(this.getFilesDir(), FILE_EXTRACTED);
Document dom = builder.parse(file);
Element root = dom.getDocumentElement();
root.normalize();
  • 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-10T14:42:27+00:00Added an answer on June 10, 2026 at 2:42 pm

    Use below Code for parse xml from url in android

    public class XMLParsingDOMExample extends Activity {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            /** Create a new layout to display the view */
            LinearLayout layout = new LinearLayout(this);
            layout.setOrientation(1);
    
            /** Create a new textview array to display the results */
            TextView name[];
            TextView website[];
            TextView category[];
    
            try {
    
                URL url = new URL("http://www.androidpeople.com/wp-content/uploads/2010/06/example.xml");
                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                DocumentBuilder db = dbf.newDocumentBuilder();
                Document doc = db.parse(new InputSource(url.openStream()));
                doc.getDocumentElement().normalize();
    
                NodeList nodeList = doc.getElementsByTagName("item");
    
                /** Assign textview array lenght by arraylist size */
                name = new TextView[nodeList.getLength()];
                website = new TextView[nodeList.getLength()];
                category = new TextView[nodeList.getLength()];
    
                for (int i = 0; i < nodeList.getLength(); i++) {
    
                    Node node = nodeList.item(i);
    
                    name[i] = new TextView(this);
                    website[i] = new TextView(this);
                    category[i] = new TextView(this);
    
                    Element fstElmnt = (Element) node;
                    NodeList nameList = fstElmnt.getElementsByTagName("name");
                    Element nameElement = (Element) nameList.item(0);
                    nameList = nameElement.getChildNodes();
                    name[i].setText("Name = " + ((Node) nameList.item(0)).getNodeValue());
    
                    NodeList websiteList = fstElmnt.getElementsByTagName("website");
                    Element websiteElement = (Element) websiteList.item(0);
                    websiteList = websiteElement.getChildNodes();
                    website[i].setText("Website = " + ((Node) websiteList.item(0)).getNodeValue());
    
                    category[i].setText("Website Category = " + websiteElement.getAttribute("category"));
    
                    layout.addView(name[i]);
                    layout.addView(website[i]);
                    layout.addView(category[i]);
                }
            } catch (Exception e) {
                System.out.println("XML Pasing Excpetion = " + e);
            }
    
            /** Set the layout view to display */
            setContentView(layout);
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on a fairly large project that has been migrated from Ant
I currently have a Perl CGI script that parses incoming XML requests using XML::Simple
I'm using Nokogiri to parse an XML response from last.fm. I am currently returning
I'm having issues unmarshalling XML that has been validated against a schema. I have
I'm currently using the toprettyxml() function of the xml.dom module in a Python script
I'm reading some XML with PHP and currently using the DOMDocument class to do
I found a nice script to import xml using powershell http://slash4.de/tutorials/Automatic_mediawiki_page_import_powershell_script Currently I don't
I know this is a question that has been asked many times before, but
I've got a question that has been bugging me for a while now, but
I have a page that has lots of images and other code that would

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.