You cannot cast a NodeList to Node so this line:
return ((Node) doc.getElementsByTagName("thumbnail_medium")).getNodeValue();
throws a ClassCastException. So you need to get the only item in the NodeList and get its text value with this line:
return doc.getElementsByTagName("thumbnail_medium").item(0).getTextContent();
I tested this with this two methods:
@Test
public void domTestVimeo() throws ParserConfigurationException,
SAXException, IOException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(new ClassPathResource("vimeo.xml")
.getInputStream());
doc.getDocumentElement().normalize();
String val = ((Node) doc.getElementsByTagName("thumbnail_medium"))
.getNodeValue();
System.out.println(val);
}
And
@Test
public void yourTest() throws ParserConfigurationException, SAXException,
IOException {
// File fXmlFile = new File("http://vimeo.com/api/v2/video/" + 21331554
// + ".xml");
InputStream is = new ClassPathResource("vimeo.xml").getInputStream();
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(is);
doc.getDocumentElement().normalize();
String val = doc.getElementsByTagName("thumbnail_medium").item(0)
.getTextContent();
System.out.println(val);
}
The first throws a ClassCastException and the second prints http://b.vimeocdn.com/ts/137/151/137151977_200.jpg I think that is the value you are looking for.
Also, how did you read from a File object passing a a URL?