“ StartElement” Sax事件允许处理单个XML ELement。
public void startElement(String uri, String localName,
String qName, Attributes attributes)
throws SAXException {
if("row".equals(localName)) {
//this code is executed for every xml element "row"
String id = attributes.getValue("id");
String PostTypeId = attributes.getValue("PostTypeId");
String AcceptedAnswerId = attributes.getValue("AcceptedAnswerId");
//others two
// you have your att values for an "row" element
}
}
对于每个元素,您都可以访问:
有关特定细节,请参见ContentHandler实现。
再见
更新:改进了以前的代码段。