@Override
 public void characters(char[] ch, int start, int length) throws SAXException {
   if (preTag != null) {
     String content = new String(ch, start, length);
     if ("name".equals(preTag)) {
       book.setName(content);
     } else if ("price".equals(preTag)) {
       book.setPrice(Float.parseFloat(content));
     }
   }
 }
 @Override
 public void startElement(String uri, String localName, String qName, Attributes attributes)
     throws SAXException {
   if ("book".equals(qName)) {
     book = new Book();
     book.setId(Integer.parseInt(attributes.getValue(0)));
   }
   preTag = qName; // 将正在解析的节点名称赋给preTag
 }