This is how I have done it. When there are no more entries it exists

 

try{

            

            try{

            

            String stationfeed = urls;

            url = new URL(stationfeed);

            ((xmlName)this.getApplication()).setXMLName(urls);

            

            URLConnection connection;

            connection = url.openConnection();

            HttpURLConnection httpConnection =
(HttpURLConnection)connection;

            int responseCode = httpConnection.getResponseCode();

            

            if (responseCode == HttpURLConnection.HTTP_OK){

                  InputStream in = httpConnection.getInputStream();

                  DocumentBuilderFactory dbf;

                  dbf = DocumentBuilderFactory.newInstance();

                  DocumentBuilder db = dbf.newDocumentBuilder();

                  

                  //Parse the feed

                  Document dom = db.parse(in);

                  Element docEle = dom.getDocumentElement();

                  

                  //Get list of each entry

                  NodeList nl = docEle.getElementsByTagName("stations");

                  if (nl != null && nl.getLength() > 0){

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

                              Element entry = (Element)nl.item(i);

                              Element sname =
(Element)entry.getElementsByTagName("StationName").item(0);

                              Element sloc =
(Element)entry.getElementsByTagName("StationLocation").item(0);

                              Element sid =
(Element)entry.getElementsByTagName("StationId").item(0);

                              Element sdis =
(Element)entry.getElementsByTagName("StationDistance").item(0);

                              Element stype =
(Element)entry.getElementsByTagName("StationPredictions").item(0);

                              

                              String namer =
sname.getFirstChild().getNodeValue();

                              String loc =
sloc.getFirstChild().getNodeValue();

                              String ids =
sid.getFirstChild().getNodeValue();

                              String dis =
sdis.getFirstChild().getNodeValue();

                              String types =
stype.getFirstChild().getNodeValue();

                              

                              //Add the station to the list

                              //Stations station = new Stations(namer, loc,
ids, dis, types);

                              submitStation(namer, loc, ids, dis, types);

                        }

                  }

            }

      }catch (MalformedURLException e){

            e.printStackTrace();

      }catch (IOException e){

            e.printStackTrace();

      }catch (ParserConfigurationException e){

            e.printStackTrace();

      }catch (SAXException e){

            e.printStackTrace();

      }

      finally{

            

      }

      }else{

            //RETURN AN ERROR

      }

 

}

 

I hope this helps you in some way.

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Kevin Duffey
Sent: Wednesday, February 03, 2010 12:36 PM
To: [email protected]
Subject: Re: [android-developers] Re: XML Parsing

 

If you're using xml pull.. just go until you find the start_tag + the name
of the node you need, then exit out of the while loops.

On Wed, Feb 3, 2010 at 8:18 AM, Frank Weiss <[email protected]> wrote:

Add a boolean variable that is set on segfirstroute startElement and cleared
on segfirstroute endElement. Us it to ignore the date element.

-- 
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]
<mailto:android-developers%[email protected]> 
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

 

-- 
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

-- 
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

Reply via email to