RSS Feed Parser Android

hendl

Erfahrenes Mitglied
Hi
Kann mir bitte jemand helfen. Habe folgendes Problem:
1) Rss Feed wird vom Internet abgerufen und dann per SaxParser geparst. Dies funktioniert auch sehr gut bei Heise.de Links aber bei allen anderen Feeds wird der Link nicht richtig herausgeparst.
Bsp. Heise
XML:
<div style="clear: both;"></div><div class="entry"><h3><a href="http://www.heise.de/newsticker/meldung/BKA-ruft-nach-erfolgreicher-Fahndung-zur-Loeschung-von-Bildern-auf-1813869.html/from/atom10">BKA ruft nach erfolgreicher Fahndung zur Löschung von Bildern auf</a><div class="lastUpdated">Donnerstag, 28. Februar 2013 15:29</div></h3><div xml:base="http://www.heise.de/newsticker/heise-top-atom.xml" class="feedEntryContent">Das
 Bundeskriminalamt fordert die Medien auf, die für eine – erfolgreiche –
 Fahndung veröffentlichten Bilder nicht mehr zu verwenden.</div>
Bsp. CNN
XML:
<div style="clear: both;"></div><div class="entry"><h3><a href="http://rss.cnn.com/%7Er/rss/edition_world/%7E3/w7QUcOyqrrY/index.html">Syrian army showing strains of war</a><div class="lastUpdated">Montag, 11. Februar 2013 14:59</div></h3><div xml:base="http://rss.cnn.com/rss/edition_world.xml" class="feedEntryContent">Government soldiers in Homs are showing the strain of war against opposition forces the government refers to as "terrorists."<img width="1" height="1" src="CNN.com%20-%20World-Dateien/w7QUcOyqrrY.gif" xml:base="http://rss.cnn.com/rss/edition_world.xml" /></div></div><div style="clear: both;"></div><div class="entry"><h3><a href="http://rss.cnn.com/%7Er/rss/edition_world/%7E3/6tu0ozfyTY8/index.html">They call it the 'final battle'</a><div class="lastUpdated">Donnerstag, 21. Februar 2013 16:56</div></h3><div xml:base="http://rss.cnn.com/rss/edition_world.xml" class="feedEntryContent">Here
 in the north, rebels call it "the final battle." For more than a month,
 lightly armed fighters have hurled themselves against a well-fortified 
helicopter base located less than a 15-minute drive from the border with
 Turkey.<img width="1" height="1" src="CNN.com%20-%20World-Dateien/6tu0ozfyTY8.gif" xml:base="http://rss.cnn.com/rss/edition_world.xml" /></div>
Beim Parsen kommt dann als Link immer nur ein leerer String raus.

Das ist der verwendete Code der bei Heise.de sehr gut funktioniert:
Java:
public void startElement(String namespaceURI, String localName,
			String qName, Attributes atts) throws SAXException {
		
		if ( localName.equals("item")|| localName.equals("entry")) {
			this.entryBoolean = true;
		} else if (localName.equalsIgnoreCase("title")) {
			this.titleBoolean = true;
		} else if (localName.equals("link")) {
			
			if (entryBoolean) {

//				Log.i(Handler.class.getSimpleName(),
//						atts.getValue(this.LINK_ATTR_HREF));	
				myContent.setUrl(atts.getValue(this.LINK_ATTR_HREF));
			}
		}
	}
 
Zuletzt bearbeitet von einem Moderator:
Zurück