简体   繁体   English

从JSoup库导入什么类,以便能够使用“ getElement”类

[英]What class to import from JSoup library to be able to use the “getElement” classes

I am trying to find elements in an html page using Jsoup and I need to use the getElementsByAttributeValue class along with all the getElement classes. 我试图找到使用Jsoup在HTML页面中的元素,我需要使用getElementsByAttributeValue类的所有一起getElement类。

The error showing in netbeans 8.0 is: netbeans 8.0中显示的错误是:

"cant find symbol" “找不到符号”

so I suppose I haven't import the proper class in the head of the program. 所以我想我没有在程序的开头导入适当的类。 So what do I have to "import" to be able to use the getElement classes or if the problem is not in the "import" thing whats going on? 那么我必须“导入”才能使用getElement类,或者如果问题不在“导入”中,那又是怎么回事?

I can not use any of getElement by the way (is not only getElementsByAttributeValue ) and I am using other classes of Jsoup like select with no problem. 我不能使用任何getElement方式(不仅是getElementsByAttributeValue ),而且我正在使用Jsoup的其他类,例如select,没有问题。

getElementsByAttributeValueorg.jsoup.nodes.Element类的方法,因此,如果您有此类的对象,则应该可以访问该方法。

Ok, some how i solved the problem with this code: 好的,我如何用以下代码解决问题:

`package sectors;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;

public class TomaDatos  {

public void nombre()throws IOException{


    String ubic = "D:\\Varios\\Trabajo\\Bolsa\\sectorpp.docx";

    FileInputStream file = new FileInputStream(new File(ubic));

    XWPFDocument doc = new XWPFDocument(file);   
    XWPFWordExtractor ex = new XWPFWordExtractor(doc);

}


}`

I really don´t know where exactly the problem was. 我真的不知道问题出在哪里。 The only important change was add XWPF after the "new" sentence here: XWPFWordExtractor ex = new XWPFWordExtractor(doc); 唯一重要的更改是在此处的“新”句子后面添加XWPF: XWPFWordExtractor ex = new XWPFWordExtractor(doc); But beleave me i tried that before and didnt work. 但是请相信我,我之前尝试过,但没有成功。 Maybe is a problem with netbeans. 也许是netbeans的问题。 I am sorry that i can not find the error, anyway, hope this work for someone.... 抱歉,我找不到错误,希望对某人有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM