Here below you can see the code.
public static void main(String[] args) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
factory.setIgnoringElementContentWhitespace(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse("http://rss.adnkronos.com/RSS_Politica.xml");
NodeList nodes = doc.getElementsByTagName("title");
for(int k=0; k < nodes.getLength(); k++) {
System.out.print(nodes.item(k));
}
}
The link of the RSS feed is the following: http://rss.adnkronos.com/RSS_Politica.xml
The result (in the console) is the following:
null null null null null null null null null null null null null null null null null null null null null
The value of nodes title, as you can see in the xml, is not null obviously.
After the result, the following errors are shown (translated from italian).
Error: URI=http://rss.adnkronos.com/RSS_Politica.xml Line=1: The root element "rss" must match the root DOCTYPE "null".
Error: URI=http://rss.adnkronos.com/RSS_Politica.xml Line=1: Document is invalid: no grammar found.