【发布时间】:2017-08-30 12:26:57
【问题描述】:
我在使用 sax 解析 xml 文件时遇到了一些问题。
Java 内容处理程序代码如下所示:
boolean rcontent = false;
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (qName.equalsIgnoreCase("content")) {
rcontent = true;
}
}
@Override
public void characters(char ch[], int start, int length) throws SAXException {
if (rcontent){
System.out.println("content: " + new String(ch, start, length));
rcontent = false;
}
}
但是输出是:
我想说
这不完整。
【问题讨论】: