quill wrote:
> My app will recieve html data from Internet. And I want to pick up
> some usful information in the data. So I use:
>
> Reader reader = new InputStreamReader(entity.getContent());
> InputSource inputsource = new InputSource(reader);
> DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
> DocumentBuilder db = dbf.newDocumentBuilder();
> Document doc = db.parse(inputsource);
> Element e = (Element) doc.getElementsByTagName("title").item(0);
>
> Logcat showed a SAXParserExcetion:expected:/linK read: head(position
> END_TAG</HEAD>....
> Am I on the right way?
No.
> Or javax.xml.parsers.DocumentBuilder can't be used to parse html?
It can only be used to parse XHTML. HTML supports many things that are
not valid XML (e.g., <br> as a standalone tag).
> How should I do?
http://java-source.net/open-source/html-parsers
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy
Android App Developer Training: http://commonsware.com/training.html
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---