I know, malformed XML content is invalid and you should not work with it – but I have no other opportunity. I want to parse the website of a service and there is a missing closing tag.
I am using the XMLPullParser from Android and I get this exception:
XmlPullParserException: expected: /div read: a (position:END_TAG </a>@40:104)
The problem is this part:
<div id="header_right">
<img src="/templates/stw_green_wide/images/header.png" width="800px" height="92px" alt="" /></a>
</div>
I don’t want to use a third party library if its not really necessary.
Regards and happy new year!
Try setting the “RELAXED FEATURE” on the parser. It will be more lenient. See docs:
BUT… I also note your trying to parse HTML with that XML Parser. Your going to run into issues because HTML is NOT XML and many sites do not use xhtml. You will create a lot less headaches for yourself if you use an HTML Parser instead. I’ve not used this one but I hear it works pretty well on Android. I am sure there are others which you can find with a little googlology. But I would strongly recommend you use an HTML parser to parse HTML 🙂
http://jsoup.org/