I really need someone help in trying to get my parser to read and show
just one section of xml file, i can get it two read from top to bottom
but when i try and use the inner tags in my xml handler that separate
each section out it doesn't do it and goes mental and shows one bit of
it
import java.net.URL;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
//import android.content.Intent;
import android.os.Bundle;
//import android.view.View;
//import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
public class Mainweather extends Seskanoreweatherpart2Activity {
weatherlist sitesList = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(1);
layout.setBackgroundColor(0xFF000080);
TextView value [];
try {
/** Handling XML */
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
/** Send URL to parse XML Tags */
URL sourceUrl = new URL(
"http://www.seskanore.com/currentoutput.xml");
/** Create handler to handle XML Tags ( extends
DefaultHandler ) */
XMLhandler XMLhandler = new XMLhandler();
xr.setContentHandler(XMLhandler);
xr.parse(new InputSource(sourceUrl.openStream()));
} catch (Exception e) {
System.out.println("XML Pasing Excpetion = " + e);
}
/** Get result from XMLhandler SitlesList Object */
sitesList = XMLhandler.sitesList;
/** Assign textview array lenght by arraylist size */
// item = new TextView[sitesList.getName().size()];
value = new TextView[sitesList.getName().size()];
/** Set the result text in textview and add it to layout */
for (int i = 0; i < sitesList.getName().size(); i++) {
value[i] = new TextView(this);
value[i].setText(sitesList.getvalue().get(i)+ " is "
+sitesList.getitem().get(i));
layout.addView(value[i]);
}
/** Set the layout view to display */
setContentView(layout);
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en