public static List getAllBook() throws Exception{ List allBookList = new ArrayList();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse("books.xml");  
NodeList bookElements = document.getElementsByTagName("book");
for(int i = 0 ; i < bookElements.getLength() ; i++){
Node node = bookElements.item(i);
Element bookEle = (Element)node;
String id = bookEle.getAttribute("id");
String title = "";
String price = "";

NodeList childList = bookEle.getChildNodes();
System.out.println( id + ":" + childList.getLength());
for(int c = 0 ; c < childList.getLength() ; c++){
Node childNode = childList.item(c);
String childName = childNode.getNodeName();
if("title".equals(childName)){
title = childNode.getTextContent();
}
}
//创建JavaBean Book对象
Book book = new Book();
book.setId(id);
book.setPrice(price);
book.setTitle(title);

//将保存所有数据的对象Book添加到list中
allBookList.add(book);

}
return allBookList;
}//有一点一直想不通,想Document、Node、Element这些接口的方法为什么在上述代码中可以直接调用呢?比如说document.getElementsByTagName("book");?还有bookEle.getAttribute("id");?接口的方法都是抽象的,在API里也没有给出具体哪些类实现了这些抽象方法?求大神讲解.JavaEEAPI对象