Thank you for your answer, Mark.
I think that the open-source html-parsers in java-source.net should do
some fixes in order to run on android. Is there any version for
android?
And I find that android sdk provides android.text.Html.fromHtml(String
source) to parse html data to a Spanned type text. But I wonder if
there is any flag in this Spanned type text for me to get the
information which I want(the sdk document seems not so clearly for
me).
For example, if I want to get the title, should I use Spanned.getSpanns
(getSpanStart("title"),getSpanEnd("title"), type)? There is a title
tag in html, but getSpanStart("title") return -1.On Apr 8, 6:57 pm, Mark Murphy <[email protected]> wrote: > 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 -~----------~----~----~----~------~----~------~--~---

