Android XML Parsing using Xml Pull Parser

Here is source code of the Program demonstrate Parsing Xml using Xml pull parser in Android. The program is successfully compiled and run on a Windows system using Eclipse Ide. The program output is also shown below.

In this example we are going to parse an Xml that we receive from the internet particularly from http://developer.yahoo.com/yql/console/ from here go to the bottom right corner in DATA TABLES and select Show Community Table and scroll dowm to yahoo and click on yahoo.finance.quote in the console that appears and type the following sql statement – select * from yahoo.finance.quote where symbol in (“MSFT”) , and uncheck Diagnostics and click on test , now u will get the following shown output –

yahoo

Now the Xml that appears in the console we actually have to download and parse in our code so that we can have our activity show us the live stocks .

Below is the Xml file that appears in the Console –

<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
    yahoo:count="1" yahoo:created="2013-07-18T17:45:46Z" yahoo:lang="en-US">
    <results>
        <quote symbol="MSFT">
            <AverageDailyVolume>49993000</AverageDailyVolume>
            <Change>-0.366</Change>
            <DaysLow>35.34</DaysLow>
            <DaysHigh>35.89</DaysHigh>
            <YearLow>26.26</YearLow>
            <YearHigh>36.43</YearHigh>
            <MarketCapitalization>295.4B</MarketCapitalization>
            <LastTradePriceOnly>35.374</LastTradePriceOnly>
            <DaysRange>35.34 - 35.89</DaysRange>
            <Name>Microsoft Corpora</Name>
            <Symbol>MSFT</Symbol>
            <Volume>22859948</Volume>
            <StockExchange>NasdaqNM</StockExchange>
        </quote>
    </results>
</query>

The XML Pull Parser API is available from the following libraries:
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
It enables you to parse an XML document in a single pass. Unlike the DOM parser, the Pull Parser presents the elements of your document in a sequential series of events and tags. Your location within the document is represented by the current event. You can determine the current event by calling getEventType. Each document begins at the START_DOCUMENT event and ends at END_DOCUMENT.

advertisement
advertisement

To proceed through the tags, simply call next, which causes you to progress through a series of
matched (and often nested) START_TAG and END_TAG events. You can extract the name of each tag by
calling getName and extract the text between each set of tags using getNextText.

This following short example demonstrates how to use the XML Pull Parser to extract details from the points of interest list returned by the Google Places API and after that we continue our class of getting xml from yahoo web service.

 
private void processStream(InputStream inputStream) {
// Create a new XML Pull Parser.
XmlPullParserFactory factory;
try {
factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser xpp = factory.newPullParser();
// Assign a new input stream.
xpp.setInput(inputStream, null);
int eventType = xpp.getEventType();
// Continue until the end of the document is reached.
while (eventType != XmlPullParser.END_DOCUMENT) {
// Check for a start tag of the results tag.
if (eventType == XmlPullParser.START_TAG &&
xpp.getName().equals(“result”)) {
eventType = xpp.next();
String name = “”;
// Process each result within the result tag.
while (!(eventType == XmlPullParser.END_TAG &&
xpp.getName().equals(“result”))) {
// Check for the name tag within the results tag.
if (eventType == XmlPullParser.START_TAG &&
xpp.getName().equals(“name”))
// Extract the POI name.
name = xpp.nextText();
 
// Move on to the next tag.
eventType = xpp.next();
}
// Do something with each POI name.
}
// Move on to the next result tag.
eventType = xpp.next();
}
} catch (XmlPullParserException e) {
Log.d(“PULLPARSER”, “XML Pull Parser Exception”, e);
} catch (IOException e) {
Log.d(“PULLPARSER”, “IO Exception”, e);
}
}

Main Activity

 
package com.example.stockquote;
 
import java.util.Arrays;
 
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
 
public class MainActivity extends Activity implements OnClickListener {
 
    public final static String STOCK_SYMBOL = "com.example.stockquotes.STOCK";
 
    private SharedPreferences stockSymbolsEntered;
 
    private TableLayout stockTableScrollView;
 
    private EditText stockSymbolEditText;
    Button enterStockSymbol;
    Button deleteStocksdata;
 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        stockSymbolsEntered = getSharedPreferences("stockList", MODE_PRIVATE);
 
        stockTableScrollView = (TableLayout) findViewById(R.id.stockTableScrollView);
        stockSymbolEditText = (EditText) findViewById(R.id.stockSymbolEditText);
        enterStockSymbol = (Button) findViewById(R.id.enterStockSymbolButton);
        deleteStocksdata = (Button) findViewById(R.id.deleteStocksButton);
 
        enterStockSymbol.setOnClickListener(this);
        deleteStocksdata.setOnClickListener(this);
 
        updateSavedStockList(null);
    }
 
    private void updateSavedStockList(String newStockSymbol) {
 
        String[] stocks = stockSymbolsEntered.getAll().keySet()
                .toArray(new String[0]);
        Arrays.sort(stocks, String.CASE_INSENSITIVE_ORDER);
 
        if (newStockSymbol != null) {
            insertStockInScrollView(newStockSymbol,
                    Arrays.binarySearch(stocks, newStockSymbol));
 
        } else {
            for (int i = 0; i < stocks.length; ++i) {
 
                insertStockInScrollView(stocks[i], i);
 
            }
 
        }
 
    }
 
    private void saveStockSymbol(String newstock) {
        String isTheStockNew = stockSymbolsEntered.getString(newstock, null);
 
        SharedPreferences.Editor preferencesEditor = stockSymbolsEntered.edit();
        preferencesEditor.putString(newstock, newstock);
        preferencesEditor.apply();
 
        if (isTheStockNew == null) {
            updateSavedStockList(newstock);
        }
 
    }
 
    private void insertStockInScrollView(String stock, int arrayIndex) {
 
        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View newStockRow = inflater.inflate(R.layout.stock_quote_row, null);
 
        TextView newStockTextView = (TextView) newStockRow
                .findViewById(R.id.stockSymbolTextView);
 
        newStockTextView.setText(stock);
 
        Button stockQuoteButton = (Button) newStockRow
                .findViewById(R.id.stockQuoteButton);
        stockQuoteButton.setOnClickListener(getStockActivityListener);
 
        Button quoteFromWebButton = (Button) newStockRow
                .findViewById(R.id.quoteFromWebButton);
        quoteFromWebButton.setOnClickListener(getStockFromWebsiteListener);
 
        stockTableScrollView.addView(newStockRow, arrayIndex);
 
    }
 
    private void deleteAllStocks() {
        stockTableScrollView.removeAllViews();
    }
 
    public OnClickListener getStockFromWebsiteListener = new OnClickListener() {
 
        public void onClick(View v) {
 
            TableRow tableRow = (TableRow) v.getParent();
            TextView stockTextView = (TextView) tableRow
                    .findViewById(R.id.stockSymbolTextView);
            String stockSymbol = stockTextView.getText().toString();
            String stockURL = getString(R.string.yahoo_stock_url) + stockSymbol;
 
            Intent getStockWebPage = new Intent(Intent.ACTION_VIEW,
                    Uri.parse(stockURL));
 
            startActivity(getStockWebPage);
 
        }
 
    };
 
    public OnClickListener getStockActivityListener = new OnClickListener() {
 
        public void onClick(View v) {
 
            TableRow tableRow = (TableRow) v.getParent();
            TextView stockTextView = (TextView) tableRow
                    .findViewById(R.id.stockSymbolTextView);
            String stockSymbol = stockTextView.getText().toString();
            Intent intent = new Intent(MainActivity.this,
                    StockInfoActivity.class);
 
            intent.putExtra(STOCK_SYMBOL, stockSymbol);
 
            startActivity(intent);
 
        }
 
    };
 
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
 
    @Override
    public void onClick(View arg0) {
        // TODO Auto-generated method stub
 
        switch (arg0.getId()) {
        case R.id.enterStockSymbolButton:
            if (stockSymbolEditText.getText().length() > 0) {
 
                saveStockSymbol(stockSymbolEditText.getText().toString());
 
                stockSymbolEditText.setText(""); // Clear EditText box
 
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(
                        stockSymbolEditText.getWindowToken(), 0);
            } else {
 
                // Create an alert dialog box
                AlertDialog.Builder builder = new AlertDialog.Builder(
                        MainActivity.this);
 
                builder.setTitle(R.string.invalid_stock_symbol);
                builder.setMessage(R.string.missing_stock_symbol);
                AlertDialog theAlertDialog = builder.create();
                theAlertDialog.show();
 
            }
            break;
 
        case R.id.deleteStocksButton:
            deleteAllStocks();
 
            SharedPreferences.Editor preferencesEditor = stockSymbolsEntered
                    .edit();
            preferencesEditor.clear();
            preferencesEditor.apply();
 
            break;
        }
    }
}

StockInfo

 
package com.example.stockquote;
 
public class StockInfo {
 
    private String daysLow = "";
    private String daysHigh = "";
    private String yearLow = "";
    private String yearHigh = "";
    private String name = "";
    private String lastTradePriceOnly = "";
    private String change = "";
    private String daysRange = "";
 
    public String getDaysLow() {
        return daysLow;
    }
 
    public String getDaysHigh() {
        return daysHigh;
    }
 
    public String getYearLow() {
        return yearLow;
    }
 
    public String getYearHigh() {
        return yearHigh;
    }
 
    public String getName() {
        return name;
    }
 
    public String getLastTradePriceOnly() {
        return lastTradePriceOnly;
    }
 
    public String getChange() {
        return change;
    }
 
    public String getDaysRange() {
        return daysRange;
    }
 
    public StockInfo(String daysLow, String daysHigh, String yearLow,
            String yearHigh, String name, String lastTradePriceOnly,
            String change, String daysRange) {
        this.daysLow = daysLow;
        this.daysHigh = daysHigh;
        this.yearLow = yearLow;
        this.yearHigh = yearHigh;
        this.name = name;
        this.lastTradePriceOnly = lastTradePriceOnly;
        this.change = change;
        this.daysRange = daysRange;
    }
 
}

StockInfoActivity

 
package com.example.stockquote;
 
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URISyntaxException;
 
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
 
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
 
import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.widget.TextView;
 
public class StockInfoActivity extends Activity {
 
    private static final String TAG = "STOCKQUOTE";
 
    TextView companyNameTextView;
    TextView yearLowTextView;
    TextView yearHighTextView;
    TextView daysLowTextView;
    TextView daysHighTextView;
    TextView lastTradePriceOnlyTextView;
    TextView changeTextView;
    TextView daysRangeTextView;
 
    static final String KEY_ITEM = "quote";
    static final String KEY_NAME = "Name";
    static final String KEY_YEAR_LOW = "YearLow";
    static final String KEY_YEAR_HIGH = "YearHigh";
    static final String KEY_DAYS_LOW = "DaysLow";
    static final String KEY_DAYS_HIGH = "DaysHigh";
    static final String KEY_LAST_TRADE_PRICE = "LastTradePriceOnly";
    static final String KEY_CHANGE = "Change";
    static final String KEY_DAYS_RANGE = "DaysRange";
    String name = "";
    String yearLow = "";
    String yearHigh = "";
    String daysLow = "";
    String daysHigh = "";
    String lastTradePriceOnly = "";
    String change = "";
    String daysRange = "";
 
    String yahooURLFirst = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quote%20where%20symbol%20in%20(%22";
    String yahooURLSecond = "%22)&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";
 
    String[][] xmlPullParserArray = { { "AverageDailyVolume", "0" },
            { "Change", "0" }, { "DaysLow", "0" }, { "DaysHigh", "0" },
            { "YearLow", "0" }, { "YearHigh", "0" },
            { "MarketCapitalization", "0" }, { "LastTradePriceOnly", "0" },
            { "DaysRange", "0" }, { "Name", "0" }, { "Symbol", "0" },
            { "Volume", "0" }, { "StockExchange", "0" } };
 
    int parserArrayIncrement = 0;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        setContentView(R.layout.activity_stock_info);
        Intent intent = getIntent();
        String stockSymbol = intent.getStringExtra(MainActivity.STOCK_SYMBOL);
 
        companyNameTextView = (TextView) findViewById(R.id.companyNameTextView);
        yearLowTextView = (TextView) findViewById(R.id.yearLowTextView);
        yearHighTextView = (TextView) findViewById(R.id.yearHighTextView);
        daysLowTextView = (TextView) findViewById(R.id.daysLowTextView);
        daysHighTextView = (TextView) findViewById(R.id.daysHighTextView);
        lastTradePriceOnlyTextView = (TextView) findViewById(R.id.lastTradePriceOnlyTextView);
        changeTextView = (TextView) findViewById(R.id.changeTextView);
        daysRangeTextView = (TextView) findViewById(R.id.daysRangeTextView);
 
        Log.d(TAG, "Before URL Creation " + stockSymbol);
 
        // Create the YQL query
        final String yqlURL = yahooURLFirst + stockSymbol + yahooURLSecond;
 
        new MyAsyncTask().execute(yqlURL);
 
    }
 
    private class MyAsyncTask extends AsyncTask<String, String, String> {
 
        protected String doInBackground(String... args) {
 
            try {
 
                Log.d("test", "In XmlPullParser");
 
                XmlPullParserFactory factory = XmlPullParserFactory
                        .newInstance();
                factory.setNamespaceAware(true);
 
                XmlPullParser parser = factory.newPullParser();
 
                parser.setInput(new InputStreamReader(getUrlData(args[0])));
                beginDocument(parser, "query");
                int eventType = parser.getEventType();
 
                do {
 
                    nextElement(parser);
                    parser.next();
 
                    eventType = parser.getEventType();
                    if (eventType == XmlPullParser.TEXT) {
                        String valueFromXML = parser.getText();
 
                        xmlPullParserArray[parserArrayIncrement++][1] = valueFromXML;
 
                    }
 
                } while (eventType != XmlPullParser.END_DOCUMENT);
 
            }
 
            catch (ClientProtocolException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (XmlPullParserException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (URISyntaxException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
 
            finally {
            }
 
            return null;
        }
 
        public InputStream getUrlData(String url) throws URISyntaxException,
                ClientProtocolException, IOException {
 
            DefaultHttpClient client = new DefaultHttpClient();
            HttpGet method = new HttpGet(new URI(url));
 
            HttpResponse res = client.execute(method);
 
            return res.getEntity().getContent();
        }
 
        public final void beginDocument(XmlPullParser parser,
                String firstElementName) throws XmlPullParserException,
                IOException {
            int type;
            while ((type = parser.next()) != parser.START_TAG
                    && type != parser.END_DOCUMENT) {
                ;
            }
 
                        if (type != parser.START_TAG) {
                throw new XmlPullParserException("No start tag found");
            }
 
            if (!parser.getName().equals(firstElementName)) {
                throw new XmlPullParserException("Unexpected start tag: found "
                        + parser.getName() + ", expected " + firstElementName);
            }
        }
 
        public final void nextElement(XmlPullParser parser)
                throws XmlPullParserException, IOException {
            int type;
 
            while ((type = parser.next()) != parser.START_TAG
                    && type != parser.END_DOCUMENT) {
                ;
            }
        }
        protected void onPostExecute(String result) {
 
            companyNameTextView.setText(xmlPullParserArray[9][1]);
            yearLowTextView.setText("Year Low: " + xmlPullParserArray[4][1]);
            yearHighTextView.setText("Year High: " + xmlPullParserArray[5][1]);
            daysLowTextView.setText("Days Low: " + xmlPullParserArray[2][1]);
            daysHighTextView.setText("Days High: " + xmlPullParserArray[3][1]);
            lastTradePriceOnlyTextView.setText("Last Price: "
                    + xmlPullParserArray[7][1]);
            changeTextView.setText("Change: " + xmlPullParserArray[1][1]);
            daysRangeTextView.setText("Daily Price Range: "
                    + xmlPullParserArray[8][1]);
 
        }
 
    }
 
}

Main.xml

advertisement
 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/tableLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:stretchColumns="yes"
    tools:context=".MainActivity" >
 
    <TableRow
        android:id="@+id/tableRow0"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
 
        <TextView
            android:id="@+id/enterSymbolTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/stock_symbol" />
        <EditText
            android:id="@+id/stockSymbolEditText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="text"
            android:layout_weight="1" >
 
            <requestFocus />
        </EditText>
 
        <Button
            android:id="@+id/enterStockSymbolButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/enter_stock_symbol" />
 
    </TableRow>
 
    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/egg_shell" >
        <TextView
            android:id="@+id/stockSymbolTextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_span="2"
            android:gravity="center_horizontal"
            android:padding="5dp"
            android:text="@string/stock_symbol_list"
            android:textColor="@color/black"
            android:textSize="@dimen/stock_list_text_size" />
 
    </TableRow>
 
    <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@color/egg_shell" >
        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_span="2"
            android:padding="5dp" >
 
            <TableLayout
                android:id="@+id/stockTableScrollView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:stretchColumns="yes" >
            </TableLayout>
        </ScrollView>
 
    </TableRow>
 
    <TableRow
        android:id="@+id/tableRow3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
 
        <Button
            android:id="@+id/deleteStocksButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/delete_all_symbols"
            android:layout_span="2" 
            android:layout_weight="1" />
 
    </TableRow>
 
</TableLayout>

Activity_stock.xml

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
 
    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
 
        <TextView
            android:id="@+id/companyNameTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="@dimen/activity_horizontal_margin"
            android:text="Medium Text"
            android:textAppearance="?android:attr/textAppearanceMedium" />
 
    </TableRow>
 
    <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
 
        <TextView
            android:id="@+id/yearLowTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="@dimen/activity_horizontal_margin"
            android:text="@string/stock_year_low" 
            android:layout_weight="1" />
 
        <TextView
            android:id="@+id/yearHighTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/stock_year_high" 
            android:layout_weight="1" />
 
    </TableRow>
 
    <TableRow
        android:id="@+id/tableRow3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/activity_horizontal_margin" >
 
        <TextView
            android:id="@+id/daysLowTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/stock_days_low"
            android:layout_weight="1" />
 
        <TextView
            android:id="@+id/daysHighTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/stock_days_high"
            android:layout_weight="1" />
 
    </TableRow>
 
    <TableRow
        android:id="@+id/tableRow4"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/activity_horizontal_margin" >
 
        <TextView
            android:id="@+id/lastTradePriceOnlyTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/last_trade_price_only"
            android:layout_weight="1" />
 
        <TextView
            android:id="@+id/changeTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/change"
            android:layout_weight="1" />
 
    </TableRow>
 
    <TableRow
        android:id="@+id/tableRow5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="@dimen/activity_horizontal_margin" >
 
        <TextView
            android:id="@+id/daysRangeTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/days_range" />
 
    </TableRow>
 
</TableLayout>

Stock_quote

advertisement
 
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/stockQuoteRow"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent"
    android:padding="@dimen/activity_horizontal_margin" >
 
    <TextView
        android:id="@+id/stockSymbolTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_span="2"
        android:layout_weight="1"
        android:textColor="@color/black"
        android:textIsSelectable="true" />
 
    <Button
        android:id="@+id/stockQuoteButton"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/get_stock_quote" />
 
    <Button
        android:id="@+id/quoteFromWebButton"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/go_to_website" />
 
</TableRow>

dom_parser1

dom_parser2

dom_parser3

dom_parser4

Sanfoundry Global Education & Learning Series – 100+ Java Android Tutorials.

If you wish to look at all Tutorials, go to Java Android Tutorials.

If you find any mistake above, kindly email to
[email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.