1

I'm trying to parse an XML file from the following website provided in the URL section, but I get the error that I have included at the end, don't know what the error says. thanks in advance for your help!

package com.lynda.files;

import java.io.IOException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class Main {

public static void main(String[] args) {

    try {
           DocumentBuilderFactory factory = 
                DocumentBuilderFactory.newInstance();
           DocumentBuilder builder = factory.newDocumentBuilder();
           Document doc = builder.parse("http://adaam.ir/");

        NodeList list = doc.getElementsByTagName("html");
        System.out.println("there are " + list.getLength() + " htmls") ;
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

}

The Error:

[Fatal Error] :1:4832: The entity "raquo" was referenced, but not declared. org.xml.sax.SAXParseException; systemId: https://knowtechie.com/how-one- company-plans-on-monetizing-your-time/; lineNumber: 1; columnNumber: 4832; The entity "raquo" was referenced, but not declared. at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at javax.xml.parsers.DocumentBuilder.parse(Unknown Source) at com.lynda.files.ReadXML.main(ReadXML.java:21)

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Farzin
  • 13
  • 2

0 Answers0