简单用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/EdRIM7JnG9z9uzZM2fOnD179rz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MoYXmMs/sHEniCoyDAPxRjetBlgGP9qcedCyBt5TAX/ZIYg7XmMI8MwAC8Ewl7ot1owlrVjkEqeuGlmOqpyZxXwygIKrw+yDnlEueV0l/8E9B/iNaSYZpYW+OIKqu+Kr8PgigMML/TpoODrCcCe4gFASwrAnuIABY1uAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkOAgAAgJDgKAkPw/5HQxn6Sglw8AAAAASUVORK5CYII=" alt="" />
用JAXP的SAX方式解析XML文件的更多相关文章
-
用JAXP的dom方式解析XML文件
用JAXP的dom方式解析XML文件,实现增删改查操作 dom方式解析XML原理 XML文件 <?xml version="1.0" encoding="UTF-8 ...
-
Java&;Xml教程(五)使用SAX方式解析XML文件
Java SAX解析机制为我们提供了一系列的API来处理XML文件,SAX解析和DOM解析方式不太一样,它并不是將XML文件内容一次性全部加载,而是连续的部分加载. javax.xml.parsers ...
-
SAX方式解析XML文件实例
books.XML文件: 书籍book.java实体类: public class Book { private String id; private String name; private Str ...
-
使用SAX方式解析XML文件
package com.pingyijinren.test; import android.util.Log; import org.xml.sax.Attributes; import org.xm ...
-
Android网络之数据解析----SAX方式解析XML数据
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/ ...
-
(四)SAX方式解析XML数据
SAX方式解析XML数据 文章来源:http://www.cnblogs.com/smyhvae/p/4044170.html 一.XML和Json数据的引入: 通常情况下,每个需要访问网络的应用程 ...
-
在iOS 开发中用GDataXML(DOM方式)解析xml文件
因为GDataXML的内部实现是通过DOM方式解析的,而在iOS 开发中用DOM方式解析xml文件,这个时候我们需要开启DOM,因为ios 开发中是不会自动开启的,只有在mac 开发中才自动开启的.我 ...
-
Java眼中的XML--文件读取--2 应用SAX方式解析XML
1.获取一个SAXParserFactory的实例.2.通过factory获取SAXParser实例. 3.新建一个包和继承自DefaultHandler的类. 因为SAX遍历方式,比如便利一个节 ...
-
DOM4J方式解析XML文件
dom4j介绍 dom4j的项目地址:http://sourceforge.net/projects/dom4j/?source=directory dom4j是一个简单的开源库,用于处理XML. X ...
随机推荐
-
VS2012 Unit Test —— 我对IdleTest库动的大手术以及对Xml相关操作进行测试的方式
[1]我的IdleTest源码地址:http://idletest.codeplex.com/ [2]IdleTest改动说明:2013年10月份在保持原有功能的情况下对其动了较大的手术,首先将基本的 ...
-
SSM整合(三):Spring4与Mybatis3与SpringMVC整合
源码下载 SSMDemo 上一节整合了Mybatis3与Spring4,接下来整合SpringMVC! 说明:整合SpringMVC必须是在web项目中,所以前期,新建的就是web项目! 本节全部采用 ...
-
canvas 动态画线
<!--实现鼠标按下的时候,移动进行绘制,鼠标抬起结束绘图,用到的事件有mousedown mousemove mouseup用的的canvas api 有 beginPath moveTo l ...
-
python-day 1
学python--脚本语言 为了更好的以后,为了更好的自己,加油!!! 1.安装虚拟机如果遇到这样的错误:此主机支持intel vt-x 处于禁用状态错误 解决方法: 进入BIOS后,找到“Syste ...
-
mongodb学习之路1
第一节 MongoDB介绍及下载与安装 引言 MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的.他支持的数据结构非常松散,是类似 json的b ...
-
<;转>;Redis 应用场景
http://blog.csdn.net/hguisu/article/details/8836819 1. MySql+Memcached 架构的问题 Memcached采用客户端-服务器的架构, ...
-
springmvc对jsonp的支持
在与前端开发人员合作过程中,经常遇到跨域名访问的问题,通常我们是通过jsonp调用方式来解决.jsop百科:http://baike.baidu.com/link?url=JKlwoETqx2uuKe ...
-
由Mifare 1卡破解带来的危险以及应对方法
今年年初以来,一个消息的传出震惊了整个IC卡行业.最近,德国和美国的研究人员成功地破解了NXP的Mifare1芯片的安全算法.Mifare1芯片主要用于门禁系统访问控制卡,以及一些小额支付卡,应用范围 ...
-
R语言︱LDA主题模型——最优主题数选取(topicmodels)+LDAvis可视化(lda+LDAvis)
每每以为攀得众山小,可.每每又切实来到起点,大牛们,缓缓脚步来俺笔记葩分享一下吧,please~ --------------------------- 笔者寄语:在自己学LDA主题模型时候,发现该模 ...
-
session、cookie与“记住我的登录状态”的功能的实现
Cookie的机制 Cookie是浏览器(User Agent)访问一些网站后,这些网站存放在客户端的一组数据,用于使网站等跟踪用户,实现用户自定义功能. Cookie的Domain和Path属性标识 ...