是否可以从startElement函数中获取元素的内容,该函数是SAX处理程序的覆盖函数?
以下是规格.
1)XML文件
<employees>
<employee id="111">
<firstName>Rakesh</firstName>
<lastName>Mishra</lastName>
<location>Bangalore</location>
</employee>
<employee id="112">
<firstName>John</firstName>
<lastName>Davis</lastName>
<location>Chennai</location>
</employee>
<employee id="113">
<firstName>Rajesh</firstName>
<lastName>Sharma</lastName>
<location>Pune</location>
</employee>
</employees>
Run Code Online (Sandbox Code Playgroud)
2)startElement功能
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
.......code in here..........
}
Run Code Online (Sandbox Code Playgroud)
3)预期结果
element name : employee
attribute name : id
attribute value: 111
firstName : Rakesh
lastName : Mishra
location : Bangalore
element name : employee
attribute name : id
attribute value: 112
firstName : …Run Code Online (Sandbox Code Playgroud)