import java.io.*; import javax.xml.parsers.*; import org.w3c.dom.*; import org.xml.sax.*; public class test { public static void main(String[] args) { Document doc = parseXmlFile("http://podcast.rtl.fr/grossestetes.xml", true); Element channel = (Element)doc.getElementsByTagName("channel").item(0); Element item = (Element)channel.getElementsByTagName("item").item(0); Element author = (Element)item.getElementsByTagNameNS("http://www.itunes.com/dtds/podcast-1.0.dtd", "author").item(0); System.out.println(author); } // Parses an XML file and returns a DOM document. // If validating is true, the contents is validated against the DTD // specified in the file. public static Document parseXmlFile(String filename, boolean validating) { try { // Create a builder factory DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(validating); // Create the builder and parse the file Document doc = factory.newDocumentBuilder().parse(filename); return doc; } catch (SAXException e) { // A parsing error occurred; the xml input is not valid System.out.println(e); } catch (ParserConfigurationException e) { System.out.println(e); } catch (IOException e) { System.out.println(e); } return null; } }