Which HTML Parser is the best?

Self plug: I have just released a new Java HTML parser: jsoup. I mention it here because I think it will do what you are after. Its party trick is a CSS selector syntax to find elements, e.g.: String html = “<html><head><title>First parse</title></head>” + “<body><p>Parsed HTML into a doc.</p></body></html>”; Document doc = Jsoup.parse(html); Elements links = … Read more

“Content is not allowed in prolog” when parsing perfectly valid XML on GAE

The encoding in your XML and XSD (or DTD) are different.XML file header: <?xml version=’1.0′ encoding=’utf-8′?>XSD file header: <?xml version=’1.0′ encoding=’utf-16′?> Another possible scenario that causes this is when anything comes before the XML document type declaration. i.e you might have something like this in the buffer: helloworld<?xml version=”1.0″ encoding=”utf-8″?> or even a space or special character. … Read more

How to parse JSON in Java

I have the following JSON text. How can I parse it to get the values of pageName, pagePic, post_id, etc.? { “pageInfo”: { “pageName”: “abc”, “pagePic”: “http://example.com/content.jpg” }, “posts”: [ { “post_id”: “123456789012_123456789012”, “actor_id”: “1234567890”, “picOfPersonWhoPosted”: “http://example.com/photo.jpg”, “nameOfPersonWhoPosted”: “Jane Doe”, “message”: “Sounds cool. Can’t wait to see it!”, “likesCount”: “2”, “comments”: [], “timeOfPost”: “1234567890” } ] }

How to read json file into java with simple JSON library

I want to read this JSON file with java using json simple library. My JSON file looks like this: [ { “name”:”John”, “city”:”Berlin”, “cars”:[ “audi”, “bmw” ], “job”:”Teacher” }, { “name”:”Mark”, “city”:”Oslo”, “cars”:[ “VW”, “Toyata” ], “job”:”Doctor” } ] This is the java code I wrote to read this file: package javaapplication1; import java.io.FileNotFoundException; import … Read more