}
else if ("publisher".equals(tag)) {
publisher = new String(ch,start,length);
}
}
@Override
public void endElement(String uri, String localName, String qName)
throws SAXException {
//将栈顶元素移除
stack.pop();
//分别将xml中的元素信息打印输出
if("resourceitem".equals(qName)){
System.out.println("id:" + id);
System.out.println("title:" + title);
System.out.println("keywords:" + keywords);
System.out.println("kind:" + kind);
System.out.println("describe:" + describe);
System.out.println("date:" + date);
System.out.println("url:" + url);
System.out.println("author:" + author);
System.out.println("publisher:" + publisher);
}
}
}
运行的结果见下图:
