Mikeymikey
New Member
I have developed an android application which reads RSS news feeds from a given URL. It works only for ".xml" format rss links. doesn't work for others. can someone help me to read from "http://www.rockstargames.com/newswire.rss" I tried to convert String fullStr to a XML document object like this.\[code\]Document doc = builder.parse(new InputSource(new StringReader(fullStr)));\[/code\]But it doesn't do the trick.this link works.(http://www.espncricinfo.com/rss/content/story/feeds/8.xml)this doesn't work. (http://www.rockstargames.com/newswire.rss)this is my code.\[code\]@Override protected Void doInBackground(Void... arg0) { try { vectParse = new Vector<HTMLRemoverBean>(); URL url = new URL("http://www.rockstargames.com/newswire.rss"); URLConnection con = url.openConnection(); BufferedReader reader = new BufferedReader( new InputStreamReader(con.getInputStream())); System.out.println("Reader :" + reader); String inputLine; String fullStr = ""; while ((inputLine = reader.readLine()) != null) fullStr = fullStr.concat(inputLine + "\n"); InputStream istream = url.openStream(); DocumentBuilder builder = DocumentBuilderFactory.newInstance() .newDocumentBuilder(); Document doc = builder.parse(istream); //Document doc = builder.parse(new InputSource(new StringReader(fullStr))); doc.getDocumentElement().normalize(); NodeList nList = doc.getElementsByTagName("item"); for (int temp = 0; temp < nList.getLength(); temp++) { Node nNode = nList.item(temp); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) nNode; objBean = new HTMLRemoverBean(); objBean.title = getTagValue("title", eElement); objBean.description = getTagValue("description", eElement); String noHTMLString = objBean.description.replaceAll( "\\<.*?\\>", ""); objBean.description = noHTMLString; objBean.link = getTagValue("link", eElement); objBean.pubdate = getTagValue("pubDate", eElement); vectParse.add(objBean); } } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return null; }\[/code\]problem is in this line.\[code\]Document doc = builder.parse(istream);\[/code\]my Logcat is here\[code\]12-24 23:19:28.146: I/Ads(8856): To get test ads on this device, call adRequest.addTestDevice(AdRequest.TEST_EMULATOR);12-24 23:19:28.296: I/Ads(8856): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"preqs":2,"session_id":"11338476729284620037","seq_num":"3","slotname":"a1504caaf0ce497","u_w":320,"msid":"com.assassins","cap":"m,a","js":"afma-sdk-a-v6.2.1","bas_off":0,"net":"ed","app_name":"1.android.com.assassins","hl":"en","gnt":3,"carrier":"310260","u_audio":4,"u_sd":1.5,"simulator":1,"isu":"B3EEABB8EE11C2BE770B684D95219ECB","cipa":0,"format":"320x50_mb","oar":0,"ad_pos":{"height":0,"visible":0,"y":172,"x":0,"width":0},"u_h":533,"testing":1,"bas_on":0,"ptime":21301});</script></head><body></body></html>12-24 23:19:28.766: I/Ads(8856): Received ad url: <url: "http://googleads.g.doubleclick.net:80/mads/gma?preqs=2&session_id=11338476729284620037&seq_num=3&u_w=320&msid=com.assassins&cap=m%2Ca&js=afma-sdk-a-v6.2.1&bas_off=0&net=ed&app_name=1.android.com.assassins&hl=en&gnt=3&carrier=310260&u_audio=4&u_sd=1.5&isu=B3EEABB8EE11C2BE770B684D95219ECB&cipa=0&format=320x50_mb&oar=0&u_h=533&bas_on=0&ptime=21301&u_so=p&adtest=on&output=html®ion=mobile_app&u_tz=-330&client_sdk=1&ex=1&slotname=a14e8f77524dde8&askip=2&gsb=3g&caps=inlineVideo_interactiveVideo_mraid1_th_autoplay_mediation_sdkAdmobApiForAds_di&jsv=41" type: "admob" afmaNotifyDt: "null" useWebViewLoadUrl: "false">12-24 23:19:28.766: I/Ads(8856): Request scenario: Online server request.12-24 23:19:29.766: D/dalvikvm(8856): GC_CONCURRENT freed 241K, 4% free 10420K/10823K, paused 23ms+20ms12-24 23:19:30.206: D/webviewglue(8856): nativeDestroy view: 0x288fa812-24 23:19:30.216: I/Ads(8856): onReceiveAd()12-24 23:19:31.336: I/System.out(8856): Reader :java.io.BufferedReader@413c1ff012-24 23:19:32.416: W/System.err(8856): org.xml.sax.SAXParseException: Unexpected end of document12-24 23:19:32.426: W/System.err(8856): at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:125)12-24 23:19:32.426: W/System.err(8856): at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:107)12-24 23:19:32.426: W/System.err(8856): at com.assassins.NewsActivity$HTMLRemoverParser.doInBackground(NewsActivity.java:118)12-24 23:19:32.426: W/System.err(8856): at com.assassins.NewsActivity$HTMLRemoverParser.doInBackground(NewsActivity.java:1)12-24 23:19:32.436: W/System.err(8856): at android.os.AsyncTask$2.call(AsyncTask.java:264)12-24 23:19:32.436: W/System.err(8856): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)12-24 23:19:32.436: W/System.err(8856): at java.util.concurrent.FutureTask.run(FutureTask.java:137)12-24 23:19:32.436: W/System.err(8856): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)12-24 23:19:32.436: W/System.err(8856): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)12-24 23:19:32.446: W/System.err(8856): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)12-24 23:19:32.446: W/System.err(8856): at java.lang.Thread.run(Thread.java:856)\[/code\]Kindly look at the code and help me. Thanks.