How to read html contents inside XML,using XlPullParser in Android project.
ex:What's inside in this
Facebook feed.
Note:it may contains images, albums, videos...
Update:i need to parse the content of ![CDATA[
Asked
Active
Viewed 647 times
0
1 Answers
0
On vogella.com, there is a nice example on how to use the XmlPullParser.
import java.io.IOException;
import java.io.StringReader;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException.html;
import org.xmlpull.v1.XmlPullParserFactory;
public class SimpleXmlPullApp {
public static void main (String args[]) throws XmlPullParserException, IOException {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser xpp = factory.newPullParser();
xpp.setInput(new StringReader ("<foo>Hello World!</foo>"));
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if(eventType == XmlPullParser.START_DOCUMENT) {
System.out.println("Start document");
} else if(eventType == XmlPullParser.END_DOCUMENT) {
System.out.println("End document");
} else if(eventType == XmlPullParser.START_TAG) {
System.out.println("Start tag "+xpp.getName());
} else if(eventType == XmlPullParser.END_TAG) {
System.out.println("End tag "+xpp.getName());
} else if(eventType == XmlPullParser.TEXT) {
System.out.println("Text "+xpp.getText());
}
eventType = xpp.next();
}
}
}

LaurentY
- 7,495
- 3
- 37
- 55

dargmuesli
- 612
- 10
- 20
-
thank you man, i successfully parsed my feed but i need to read the html inside, in a way that the web view can understand (html). – mkm Mar 30 '15 at 18:54