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

  • Home
  • SEARCH
  • 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 8254677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:16:27+00:00 2026-06-08T01:16:27+00:00

I am making an application for Android and I need to display an XML

  • 0

I am making an application for Android and I need to display an XML file of this page:http://www.bovalpo.com/cgi-local/xml_bcv.pl?URL=7009
I tried the solutions given on the page but I find it wrong since it is not displayed when you run the application. I just want to show “tipo= DOLAR SPOT INTERCAMBIO”

This is the XML CODE

XML CODE

and this is my code:

xmlpruebaprueba.jar

XMLdataCollected sitesList= null;

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


    //creando un Layout
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(1);

    //creando TextView

    TextView Registro[];
    TextView Tipo[];

    try {
        SAXParserFactory spf = SAXParserFactory.newInstance();
        SAXParser sp = spf.newSAXParser();
        XMLReader xr = sp.getXMLReader();

        URL sourceURL = new URL("http://www.bovalpo.com/cgi-local/xml_bcv.pl?URL=7009");

        handlingXml  HandlingXml = new handlingXml();
        xr.setContentHandler(HandlingXml);
        xr.parse(new InputSource(sourceURL.openStream()));
    }catch (Exception e){
        System.out.println("XML Parsing Exception= " + e);
    }


    sitesList = handlingXml.sitesList;

    Registro = new TextView[sitesList.getRegistro().size()];
    Tipo = new TextView[sitesList.getTipo().size()];

    for (int i = 0; i < sitesList.getRegistro().size(); i++) {
        Registro[i] = new TextView(this);
        Registro[i].setText("Registro = "+sitesList.getRegistro().get(i));
        Tipo[i] = new TextView(this);
        Tipo[i].setText("Tipo = "+sitesList.getTipo().get(i));

        layout.addView(Registro[i]);
        layout.addView(Tipo[i]);
    } 
} 

}


and this is my handler

Boolean currentElement = false;
String currentValue = null;
public static XMLdataCollected sitesList = null;


public static XMLdataCollected getDataCollected (){
    return sitesList;
}

public static void setSitesList(XMLdataCollected sitesList){
    handlingXml.sitesList = sitesList;
}

@Override
public void startElement(String uri, String localName, String qName,
        Attributes attributes) throws SAXException {
    // TODO Auto-generated method stub

    currentElement = true;

    if(localName.equals("Root"))
    {
        sitesList = new XMLdataCollected();
    }else if (localName.equals("Registro")){
        String attr = attributes.getValue("tipo");
        sitesList.setTipo(attr);
    }
}



@Override
public void endElement(String uri, String localName, String qName)
        throws SAXException {
    // TODO Auto-generated method stub

    currentElement = false;


    if (localName.equalsIgnoreCase("Registro"))
        sitesList.setRegistro(currentValue);
        else if (localName.equalsIgnoreCase("Root"))
        sitesList.setRoot(currentValue);    
    }

@Override
public void characters(char[] ch, int start, int length)
        throws SAXException {
    // TODO Auto-generated method stub
    if (currentElement) {
        currentValue = new String(ch, start, length);
        currentElement = false;
        }
}

}

and this is my dataCollected

public class XMLdataCollected {

private ArrayList<String> root = new ArrayList<String>();
private ArrayList<String> registro = new ArrayList<String>();
private ArrayList<String> tipo = new ArrayList<String>();

public ArrayList<String> getRoot (){
    return root;
}

public void setRoot(String root){
    this.root.add(root);
}

public ArrayList<String> getRegistro (){
    return registro;
}

public void setRegistro(String registro){
    this.registro.add(registro);
}

public ArrayList<String> getTipo (){
    return tipo; 
}

public void setTipo(String tipo){
    this.tipo.add(tipo);
}

}

  • 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-08T01:16:28+00:00Added an answer on June 8, 2026 at 1:16 am

    You are calling your Web Request on main UI thread.

    PLEASE DO NOT DO THIS

    use AsyncTask to call web your request.

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

Sidebar

Related Questions

I am making an application for Android and I need to display an XML
<?xml version=1.0 encoding=utf-8?> <manifest xmlns:android=http://schemas.android.com/apk/res/android package=com.android> <application android:icon=@drawable/ic_launcher android:label=@string/app_name> <activity android:name=.hba1c android:label=@string/app_name android:screenOrientation=portrait> <intent-filter>
I am making an android application that will play an mp3 file once a
I am making an android application that needs to display all of the items
I'm making an Android application where I need to slow down the audio being
I am making one project where i need to display Home page and when
I am currently making an android application which need to present a lot of
I am making an application for android, i need to make a request to
I am making an android application and as a part of that I need
I'm making a Android application, where I need to read the latest news from

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.