当我正在推送时,取出了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") ;
}
答案 0 :(得分:0)
就这样做,
if (eventType == XmlPullParser.START_TAG)
{
if(xpp.getName().equalsIgnoreCase("item"))
{
eventType = xpp.next();
if (eventType == XmlPullParser.TEXT)
{
Log.i(xpp.getText(), "TEXT") ;
}
}
}
所以每个标签你都要检查并做这样....