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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:44:52+00:00 2026-06-15T14:44:52+00:00

I am new in android development, I want to parse one particular xml file

  • 0

I am new in android development, I want to parse one particular xml file using Dom Parser. The xml structure is something like this.

<Images>
   <image link="a.tgcdn.net/images/products/zoom/e554_android_plush_robot.jpg"/>
   <image link="a.tgcdn.net/images/products/zoom/e554_android_plush_robot.jpg"/>
   <image link="http://cdn.androidpolice.com/wp-content/themes/ap1/images/android1.png"/>
   <image link="http://cdn.androidpolice.com/wp-content/themes/ap1/images/android1.png"/>
   <image link="http://cdn.androidpolice.com/wp-content/themes/ap1/images/android1.png"/>
</Images>

I want to add those web links in a arraylist.
suggest me some way out for it.. Even any link or tutorials related to this will be helpful. Thanks.

here is full code..

public class MainActivity extends Activity {


    String xmlurl       = "--url of xml---";


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ArrayList<String> mImageLink = new ArrayList<String>();
        try {
            URL url = new URL(xmlurl);
            XMLParser   parser  =   new XMLParser();
            String      xml     = parser.getXMLfromUrl(url);
            Document    doc     = parser.getDomElement(xml);
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc1 = db.parse(new InputSource(url.openStream()));
            doc1.getDocumentElement().normalize();

            NodeList nodeList = doc1.getElementsByTagName("photo");

            for (int i = 0; i < nodeList.getLength(); i++) {
                Element websiteElement = (Element) nodeList.item(i);
                nodeList = websiteElement.getChildNodes();              
                mImageLink.add(websiteElement.getAttribute("link"));

            }
        } catch (Exception e) {
            System.out.println("XML Pasing Excpetion = " + e);
        }

        for(int i=0;i<mImageLink.size();i++){
            Log.d("Photo link --- " + i,mImageLink.get(i));
        }

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}
  • 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-15T14:44:54+00:00Added an answer on June 15, 2026 at 2:44 pm

    Please Use below code to Parse above XML file using DOM Parser.

    public class MainActivity extends Activity {
    
        ArrayList<String> mImageLink;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            try {
                mImageLink = new ArrayList<String>();
    
                InputStream is = getResources().openRawResource(R.raw.temp);
                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                DocumentBuilder db = dbf.newDocumentBuilder();
                Document doc = db.parse(new InputSource(is));
                doc.getDocumentElement().normalize();
    
                NodeList nodeList = doc.getElementsByTagName("image");
    
                for (int i = 0; i < nodeList.getLength(); i++) {
    
                    Node node = nodeList.item(i);
    
                    Element fstElmnt = (Element) node;
    
                    mImageLink.add(fstElmnt.getAttribute("link"));
    
                }
            } catch (Exception e) {
                System.out.println("XML Pasing Excpetion = " + e);
            }
        }
    }
    

    And see below link for more information.

    XML Parsing Using DOM Parser

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

Sidebar

Related Questions

I am new to android development.I want to write logs to one file in
I am new to Android Development,and want to parse the XML and bind to
I am new to android development. I want to make one background application, so
I'm new to Android development, so I might be missing something obvious. I want
I'm new in Android development but I like it so far. I want to
I am new to android development. I want to do the login verification, using
I am new in android development, and I need advice about structure.I want to
I'm new to Android development. I want to load a html file into a
I am new to Android development and I want to run PING command through
I everyone. I'm very new to Android development and I want to develop an

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.