📄 sax1.java~2~
字号:
package xmloperation;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import java.util.*;
import java.io.*;
public class sax1 extends DefaultHandler
{
Stack tags = new Stack();
String name;
String address;
String tel;
String fax;
String email;
public sax1() {}
public void endDocument() throws SAXException
{
System.out.println("-----Parse End");
}
public void startDocument() throws SAXException
{
System.out.println("-----Parse Start");
}
public void startElement(String p0,String p1,String p2,Attributes p3) throws SAXException
{
tags.push(p2);
}
public void endElement(String p0,String p1,String p2) throws SAXException
{
tags.pop();
if(p2.equals("PERSON"))
{
printlnout();
}
}
public void characters(char[] p0,int p1,int p2) throws SAXException
{
String tag = tags.peek().toString();
if(tag.equals("NAME"))
{
name = new String(p0,p1,p2);
}
else if(tag.equals("NAME"))
{
name = new String(p0,p1,p2);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -