您的位置:首页 > 其它

SAX解析器

2015-08-03 21:01 387 查看
;

import javax.swing.DefaultBoundedRangeModel;

import org.xml.sax.Attributes;

import org.xml.sax.SAXException;

import org.xml.sax.helpers.DefaultHandler;

public class MySAXHandler extends DefaultHandler{

private boolean isArray;

@Override

public void characters(char[] ch, int start, int length) throws SAXException {

super.characters(ch, start, length);
if(isArray){
System.out.println("我终于找到这个xcz的值了"+new String(ch,start,length));
System.out.println(new String(ch,start,length));
}

}

@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {

super.startElement(uri, localName, qName, attributes);
System.out.println(localName+"标签结束"+qName);
}

@Override
public void endDocument() throws SAXException {

super.endDocument();
System.out.println("解析文档结束");
}


public void startDocument() throws SAXException {

super.startDocument();
System.out.println("解析文档开始");
}
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {

super.endElement(uri, localName, qName);
isArray=qName.equals("xcz");
System.out.println(localName+"标签开始"+qName);
}


}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: