简单用JAXP的SAX方式(事件驱动)解析XML文件:

文件(1.XML)

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<class>
<student>
<name>张三</name>
<sid>111111</sid>
</student>
<student>
<name>李四</name>
<sid>222222</sid>
</student>
</class>

 Java代码

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler; public class JaxpSax {
public static void main(String[] args) throws Exception {
SAXParserFactory factory=SAXParserFactory.newInstance();
SAXParser parser=factory.newSAXParser();
parser.parse("src/1.xml", new MyHandler1());//在控制台打印出XML文件
//parser.parse("src/1.xml", new MyHandler2());//在控制台打印所有学生姓名
}
}
class MyHandler1 extends DefaultHandler{
@Override
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
System.out.print("<"+qName+">");
}
@Override
public void characters(char[] ch, int start, int length)
throws SAXException {
System.out.print(new String(ch,start,length));
}
@Override
public void endElement(String uri, String localName, String qName)
throws SAXException {
System.out.print("</"+qName+">");
}
}
class MyHandler2 extends DefaultHandler{ boolean flag=true;
@Override
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
if(qName.equals("name")) flag=true;
}
@Override
public void characters(char[] ch, int start, int length)
throws SAXException {
if(flag) System.out.println(new String(ch,start,length));
}
@Override
public void endElement(String uri, String localName, String qName)
throws SAXException {
if(qName.equals("name")) flag=false;
}
}

控制台运行结果:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYEAAAEdCAIAAABln0xLAAAbaElEQVR4nO2dXZAcR33At4qkUqmQyguVqjzlJVVEulTxEE4lziQkBbHjVBA4HzpjC7SWxMHZWAqWLZdTCIe46s4WsrzGEhYxSDbYWGit6PThC8LgYMcI7JhTiDk/5IoyLsODhCQGf5zOOqPLw+zO9vfM7PZMz+79frUl7U5Pz/T0dP+2e2bnf7WlnomiKIqiBx98MGrz4IMPfun4j750/EdRIM7JnG9z9uzZM2fOnD179r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tD8MoYXmMs/sHEniCoyDAPxRjetBlgGP9qcedCyBt5TAX/ZIYg7XmMI8MwAC8Ewl7ot1owlrVjkEqeuGlmOqpyZxXwygIKrw+yDnlEueV0l/8E9B/iNaSYZpYW+OIKqu+Kr8PgigMML/TpoODrCcCe4gFASwrAnuIABY1uAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkPw/5HQxn6Sglw8AAAAASUVORK5CYII=" alt="" />

用JAXP的SAX方式解析XML文件的更多相关文章

  1. 用JAXP的dom方式解析XML文件

    用JAXP的dom方式解析XML文件,实现增删改查操作 dom方式解析XML原理 XML文件 <?xml version="1.0" encoding="UTF-8 ...

  2. Java&Xml教程(五)使用SAX方式解析XML文件

    Java SAX解析机制为我们提供了一系列的API来处理XML文件,SAX解析和DOM解析方式不太一样,它并不是將XML文件内容一次性全部加载,而是连续的部分加载. javax.xml.parsers ...

  3. SAX方式解析XML文件实例

    books.XML文件: 书籍book.java实体类: public class Book { private String id; private String name; private Str ...

  4. 使用SAX方式解析XML文件

    package com.pingyijinren.test; import android.util.Log; import org.xml.sax.Attributes; import org.xm ...

  5. Android网络之数据解析----SAX方式解析XML数据

    ​[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/ ...

  6. (四)SAX方式解析XML数据

    SAX方式解析XML数据 ​文章来源:http://www.cnblogs.com/smyhvae/p/4044170.html 一.XML和Json数据的引入: 通常情况下,每个需要访问网络的应用程 ...

  7. 在iOS 开发中用GDataXML(DOM方式)解析xml文件

    因为GDataXML的内部实现是通过DOM方式解析的,而在iOS 开发中用DOM方式解析xml文件,这个时候我们需要开启DOM,因为ios 开发中是不会自动开启的,只有在mac 开发中才自动开启的.我 ...

  8. Java眼中的XML--文件读取--2 应用SAX方式解析XML

    1.获取一个SAXParserFactory的实例.2.通过factory获取SAXParser实例.  3.新建一个包和继承自DefaultHandler的类.  因为SAX遍历方式,比如便利一个节 ...

  9. DOM4J方式解析XML文件

    dom4j介绍 dom4j的项目地址:http://sourceforge.net/projects/dom4j/?source=directory dom4j是一个简单的开源库,用于处理XML. X ...

随机推荐

  1. linux (RHEL) 添加和删除用户

    linux添加新用户使用 useradd -----create a new user or update default new user information 删除用户使用userdel  -- ...

  2. 【Android Studio错误】 If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.

    解决办法:以管理员身份运行cmd窗口,输入命令“netsh winsock reset” netsh winsock reset命令,作用是重置 Winsock 目录.如果一台机器上的Winsock协 ...

  3. 【leetcode】Next Permutation(middle)

    Implement next permutation, which rearranges numbers into the lexicographically next greater permuta ...

  4. eclipse的使用一

    The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files ...

  5. selinux

    root@lujie ~]# vim /etc/sysconfig/selinux # This file controls the state of SELinux on the system. # ...

  6. sql语句按照汉字拼音首字母排序

    oracle : 在oracle9i中新增了按照拼音.部首.笔画排序功能.设置NLS_SORT值SCHINESE_RADICAL_M 按照部首(第一顺序).笔划(第二顺序)排序SCHINESE_STR ...

  7. PHP安全编程:不要让不相关的人看到报错信息

    没有不会犯错的开发者,PHP的错误报告功 能可以协助你确认和定位这些错误,可以提供的这些错误的详细描述,但如果被恶意攻击者看到,这就不妙了.不能让大众看到报错信息,这一点很重要.做到这一 点很容易,只 ...

  8. osgearth使用prjected投影

    In projected mode, you have to specify a map profile (i.e. a map projection). You also need to tell ...

  9. September 16th 2016 Week 38th Friday

    All the treasures of the earth would not bring back one lost moment. 机会失去不再来,千贯万贯难赎回. Cherish your h ...

  10. 3ds max删除了对象后,还是将原来所有对象输出的原因

    原因是场景中除了 几何体 外还有 图形,如下图 将这些图形删除,几何体就都正常输出了.