0

当我放入时,获取 InoutStream

inputStream = new URL("http://www.hindu.com/rss/01hdline.xml").openStream();
InputStreamReader isr = new InputStreamReader(inputStream);

里面 ,

xpp.setInput(isr); // i am getting Text in every logs output 

但是当我从这个 xml 中放入一些 xml 部分时,

<item>
<category/>
<link>
http://www.hindu.com/2011/06/30/stories/2011063063980100.htm
</link>
<title>Talk of drift, corruption is propaganda: Manmohan</title>
<description></description>
<pubDate>Thu, 30 Jun 2011</pubDate>
</item>

it is working properly , means i am not getting Text in every log's output . like
03-15 06:08:35.199: I/rss(2354): TEXT
03-15 06:08:35.199: I/channel(2354): TEXT
03-15 06:08:35.209: I/The Hindu - Front Page(2354): TEXT
03-15 06:08:35.209: I/title(2354): TEXT
03-15 06:08:35.228: I/http://www.hindu.com/(2354): TEXT
03-15 06:08:35.228: I/link(2354): TEXT
03-15 06:08:35.249: I/The Internet edition of The Hindu, India's national newspaper(2354): TEXT

这是我的 xmlPullParser.getText() 方法,

if(eventType == XmlPullParser.TEXT) 
                {
                    Log.i(xpp.getText(), "TEXT") ;
                }
4

1 回答 1

0

就这样做,

 if (eventType == XmlPullParser.START_TAG) 
 {
  if(xpp.getName().equalsIgnoreCase("item"))
  {
    eventType = xpp.next();

    if (eventType == XmlPullParser.TEXT) 
    {
        Log.i(xpp.getText(), "TEXT") ;
    }
  }
}

所以你必须检查每个标签并这样做......

于 2013-03-15T07:46:42.443 回答