Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: jTidy install problems

  1. #1
    Join Date
    Apr 2013
    Thanked 3 Times in 3 Posts

    Default jTidy install problems

    hi i have this codde for scraping data from web site. i have downloaded jtidy and installed jtidy library to package
    but i cant seem to fix the import for:
    "Tidy tidy=new Tidy();" in method "getDocumentFromHTMLInputStream()" //tidy has red line under it
    in method getDocumentFromHTMLInputStream(){
    i have the library aded so what am i doing wrong i allways have a problem like this when i add a library but cant figure out what im doing wrong any help would be great thanks.
    the code is:

    package dompaser;

    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.InputStream;
    import java.util.Vector;
    import javax.xml.xpath.XPath;
    import javax.xml.xpath.XPathConstants;
    import javax.xml.xpath.XPathExpression;
    import javax.xml.xpath.XPathExpressionException;
    import javax.xml.xpath.XPathFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;

    class DOMParser{
    private InputStream is=null;

    public static void main(String[] args)throws FileNotFoundException{
    DOMParser parser =new DOMParser(new FileInputStream("http://sockslist.net"));
    Document d=parser.getDocumentFromHTMLInputStream();
    //this is the root of the html document in most cases its the html element
    Node root=d.getDocumentElement();
    //we can check that for ouurselfs

    //this is the part that must parse input stream
    public DOMParser(InputStream is){//constructor
    //this method uses the input stream corresponding to the
    //htmml file and returns a document corresponding to same returning a document

    public Document getDocumentFromHTMLInputStream(){
    Tidy tidy=new Tidy();//this is the object of parsing library jtidy
    Document doc=tidy.parseDom(is,null);//provoids ipstrream and no need for op strream
    return doc;

    //define an interface###############################
    //interface IValueExtractor {
    ////assuming outputs are vectors of strings
    //Vector<String> getRequiredValue(Document doc)throws XPathExpressionException;

    class ZillowValueExtractor {
    public Vector<String> getRequestedValues(Document doc)throws XPathExpressionException{
    //remember the xpath from site
    XPathFactory factory=XPathFactory.newInstance();
    XPath xpath=factory.newXPath();
    XPathExpression expr = xpath.compile("xpath location rcapfromsite");

    Object result =expr.evaluate(doc,XPathConstants.NODESET);
    NodeList nodes =(NodeList)result;
    for(int i=0;i<nodes.getLength();i++){
    System.out.println(nodes.item(i).getNodeValue());//LAST WAS JUST .getNodes()
    //todo a maunual search for xpath
    NodeList childNodes =nodes.item(0).getChildNodes();
    for(int i=0 ;i<childNodes.getLength();i++){
    if (childNodes.item(i).getNodeName().equals("strong") );{
    //if this child is a <strong> tag then the price is it child
    String price=childNodes.item(i).getChildNodes().item(0).g etValue();

    return null;

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Eastern Florida
    Thanked 2,455 Times in 2,406 Posts

    Default Re: jTidy install problems

    Please copy the full text of the compiler's error messages and post it here.

    Please edit your post and wrap your code with code tags:
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. how to install a pakcage?
    By bean in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 5th, 2013, 10:08 PM
  2. Where to install Netbeans
    By korrigan in forum Java IDEs
    Replies: 2
    Last Post: January 30th, 2013, 11:53 AM
  3. install network program
    By ferrarini in forum What's Wrong With My Code?
    Replies: 32
    Last Post: May 30th, 2012, 01:05 PM
  4. how to install the JVM?
    By warnexus in forum Java IDEs
    Replies: 3
    Last Post: September 1st, 2011, 10:33 AM