开发者

Element cannot be resolved to a type

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜