Android XML parser not parsing

I'm trying to parse XML with Android's own parser. I am using the IBM tutorial as a guide when doing this. THE CODEThe XML I'm testing with is with the following link. I am trying to parse Number and Name from it. \[code\]https://api.trafiklab.se/sl/realtid/GetSite?stationSearch=Slussen&key=7c4434c36d394e0c99396b8d1c69d9c4\[/code\]I have set up a parser class called AndroidSaxFeedParser that looks like this:\[code\]public class AndroidSaxFeedParser extends BaseFeedParser { static final String ROOT = "http://www1.sl.se/realtidws/"; public AndroidSaxFeedParser(String feedUrl) { super(feedUrl); } public List<Message> parse() { final Message currentMessage = new Message(); RootElement root = new RootElement(ROOT, "Hafas"); final List<Message> messages = new ArrayList<Message>(); Element sites = root.getChild(SITES); Element site = sites.getChild(SITE); site.setEndElementListener(new EndElementListener(){ public void end() { messages.add(currentMessage.copy()); } }); site.getChild(NUMBER).setEndTextElementListener(new EndTextElementListener(){ public void end(String body) { currentMessage.setNumber(body); } }); site.getChild(NAME).setEndTextElementListener(new EndTextElementListener(){ public void end(String body) { currentMessage.setName(body); } }); try { Xml.parse(this.getInputStream(), Xml.Encoding.UTF_8, root.getContentHandler()); } catch (Exception e) { throw new RuntimeException(e); } return messages; }}\[/code\]The BaseFeedParser that the above class extends looks like this:\[code\]public abstract class BaseFeedParser implements FeedParser { // names of the XML tags static final String SITES = "Sites"; static final String SITE = "Site"; static final String NUMBER = "Number"; static final String NAME = "Name"; private final URL feedUrl; protected BaseFeedParser(String feedUrl){ try { this.feedUrl = new URL(feedUrl); } catch (MalformedURLException e) { throw new RuntimeException(e); } } protected InputStream getInputStream() { try { return feedUrl.openConnection().getInputStream(); } catch (IOException e) { throw new RuntimeException(e); } }}\[/code\]I call the parser like this:\[code\]AndroidSaxFeedParser parser = new AndroidSaxFeedParser("https://api.trafiklab.se/sl/realtid/GetSite?stationSearch=Slussen&key=7c4434c36d394e0c99396b8d1c69d9c4");List<Message> messages = parser.parse();\[/code\](I'm not including the Message class since the problem shouldn't be there, it never gets a chance to process the messages)THE PROBLEMNone of the listeners in the AndroidSaxFeedParser ever hear anything. When I place breakpoints inside them, they are never triggered. I see that the Elements sites and site are picked up properly (I can see relevant data in the variables). It runs down to the final Xml.parse() line which executes properly but returns a blank result.Any ideas where I'm going wrong? Thanks!
 
Back
Top