import org.jsoup.*;
import org.w3c.dom.Document;
public class jsoup {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String html = "<html><head><title>First parse</title>&l开发者_开发知识库t;/head>"
+ "<body><p id='xxx'>Parsed HTML into a doc.</p></body></html>";
Document doc = (Document)Jsoup.parse(html);
Element el = doc.getElementById("xxx");
}
}
When I run code above, I receive a
error:Element cannot be resolved to a type in line "Element el = doc.getElementById("xxx");"
Can you help me?
That's just a compilation error. You need to import Element
.
import org.jsoup.nodes.Element;
Read the Jsoup javadocs for all packages and classes. They are linked in Jsoup home page. Please also note that Jsoup doesn't use Document
from org.w3c.dom
. Remove that line and the unnecessary cast.
精彩评论