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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:44:03+00:00 2026-06-06T16:44:03+00:00

I searched the net for hours, but I’m stuck. I used a tutorial for

  • 0

I searched the net for hours, but I’m stuck.

I used a tutorial for parsing xml, i came to the conclusion it would be best for me to use the DOM xml parser.
Mainly cause the content i parse contains only 30 items.

the xml looks as folowing:

<?xml version="1.0" encoding="UTF-8"?>
<sliderlist>
<item>
<urlslide>http://www.google.com</urlslide>
</item>
<item>
<urlslide>http://www.stackoverflow.com</urlslide>
</item>
</sliderlist>

The DOM parser (most from a tutorial):

TextView urlslide[];


        try {

            URL url = new URL("http://www.mydomain.com/my.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 */
            urlslide = new TextView[nodeList.getLength()];


            for (int i = 0; i < nodeList.getLength(); i++) {

                Node node = nodeList.item(i);

                urlslide[i] = new TextView(this);


                Element fstElmnt = (Element) node;
                NodeList nameList = fstElmnt.getElementsByTagName("urlslide");
                Element nameElement = (Element) nameList.item(0);
                nameList = nameElement.getChildNodes();
                urlslide[i].setText(((Node) nameList.item(0)).getNodeValue());


                //layout.addView(urlslide[i]);


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

And then the part where i need the parsed content fill me array (what now uses the xml inside the values/res folder):

        mTimer=new CountDownTimer(15000, 1000) {

    String[] myArray = getResources().getStringArray(R.array.testArray);
    //String[] myArray={"http://www.upc.nl/","http://www.google.com","http://www.flyerwall.nl"};    
     //<- String should be read from landingpage.


        int currentIndex=0; 
        public void onTick(long millisUntilFinished) {
             //if (currentIndex<myArray.length) {
                //number.setText("seconds remaining: " +  millisUntilFinished / 1000);
                //currentIndex++;
             //}
        }

        public void onFinish() {
            if (currentIndex<myArray.length) {
                //number.setText("done!");
                mWebView.loadUrl(myArray[currentIndex]);
                currentIndex++;
            } else {
                currentIndex=0;//reset current url to 0
                if (currentIndex<myArray.length)
                //number.setText("done!");
                mWebView.loadUrl(myArray[currentIndex]);
                currentIndex++;
                mTimer.start(); //activate the loop
            }

                mTimer.start();//first time start

        }
     };

I went to so much sample codes i that i not got a clue anymore,but my guts say it should be so simple to complete.

  • 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-06T16:44:04+00:00Added an answer on June 6, 2026 at 4:44 pm

    Finally i figured it out:

    try {
    
        URL url = new URL("http://www.mydomain.com/my.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");
    
        final List<String> urlList = new ArrayList<String>();
    
        for (int i = 0; i < nodeList.getLength(); i++) {
    
        Node node = nodeList.item(i);
    
    
    
        Element fstElmnt = (Element) node;
        NodeList nameList = fstElmnt.getElementsByTagName("urlslide");
        Element nameElement = (Element) nameList.item(0);
        nameList = nameElement.getChildNodes();
    
        urlList.add(((Node) nameList.item(0)).getNodeValue());
    
    
        }
    
    
        mTimer=new CountDownTimer(15000, 1000) {
    
        Object[] myArray = urlList.toArray();
        .........more code
    
    
        };//CountDownTimer ENDS
        } catch (Exception e) {
            System.out.println("XML Pasing Exception = " + e);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried everything, searched the net for two hours or even more and
Just searched the Net and came up with the following codes..When I run them
I searched the net and books, for an answer but didn't find it. (maybe
I searched the net and handbook, but I only managed to learn what is
I've searched the net but didn't found anything interesting. Maybe I'm doing something wrong.
I have searched on the net for a couple of hours. I got many
I have now searched for hours, but haven't found a solution yet. I hope
Searched the net for a jshint plugin for netbeans, but found none... Can anyone
I have searched the net and searched the net only to not quite find
I have tried dllimport and extern command without any success. Searched the net for

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.