《Java 核心技术卷2》2.1节中XML概述部分,如何高效阅读与总结?
- 内容介绍
- 文章标签
- 相关推荐
本文共计914个文字,预计阅读时间需要4分钟。
XML是一种标记语言,类似于HTML。其本意是(Extensible Markup Language)可扩展标记语言。标记语言不是一种编程语言,而是用于描述数据的工具。XML的特点是在描述事物的属性时,使用符号。
XML 是什么
类似于,HTML,是一种标记语言。XML 的本意是(Extensible Markup Language)可扩展标记语言。标记语言不是一种程序语言,是用于描述数据的工具。XML的特点是,在描述事物属性的基础上,增加了层次信息。
XML 有什么用
<item property="enable">
<name>tofu</name>
<color>white</color>
<weight>500g</weight>
<quantity>excellent</quantity>
<label>
<type>food</type>
<type2>vegetable</type2>
<type3>chill</type3>
<label>
</item>
<item property="disable">
<name>fish</name>
<color>300g</color>
<quantity>boiled</quantity>
</item>
</items>
程序捏的配置,比如配置数据库SQL
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.a.b.XXMapper" >
<resultMap id="BaseResultMap" type="com.a.b.XXVO" >
<id column="XX" property="xx" jdbcType="VARCHAR" />
<result column="XX" property="xx" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
A,B,C,D
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from XX
where XX = XX
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from XX
where XX= XX
</delete>
</mapper>
约定
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper>
</mapper>
blue
<height>2.2m</height>
</car>
不如:
<car><colur>blue</color>
<height unit="m">2.2</height>
</car>
select
<include refid="Base_Column_List" />
from XX
<![CDATA[ where XX > XX]]>
</select>
解析器
DOM
Document Object Model,文档对象模型,可修改XML, 使用简单。但是不使用于大XML文件读取,内存会急速增加。
SAX
Simple API for XML XML的简单API,可对大型XML进行筛选性的读取一部分,需要自己写解析器,使用较复杂。使用SAX解析不能进行XML修改。
本文共计914个文字,预计阅读时间需要4分钟。
XML是一种标记语言,类似于HTML。其本意是(Extensible Markup Language)可扩展标记语言。标记语言不是一种编程语言,而是用于描述数据的工具。XML的特点是在描述事物的属性时,使用符号。
XML 是什么
类似于,HTML,是一种标记语言。XML 的本意是(Extensible Markup Language)可扩展标记语言。标记语言不是一种程序语言,是用于描述数据的工具。XML的特点是,在描述事物属性的基础上,增加了层次信息。
XML 有什么用
<item property="enable">
<name>tofu</name>
<color>white</color>
<weight>500g</weight>
<quantity>excellent</quantity>
<label>
<type>food</type>
<type2>vegetable</type2>
<type3>chill</type3>
<label>
</item>
<item property="disable">
<name>fish</name>
<color>300g</color>
<quantity>boiled</quantity>
</item>
</items>
程序捏的配置,比如配置数据库SQL
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.a.b.XXMapper" >
<resultMap id="BaseResultMap" type="com.a.b.XXVO" >
<id column="XX" property="xx" jdbcType="VARCHAR" />
<result column="XX" property="xx" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
A,B,C,D
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from XX
where XX = XX
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
delete from XX
where XX= XX
</delete>
</mapper>
约定
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper>
</mapper>
blue
<height>2.2m</height>
</car>
不如:
<car><colur>blue</color>
<height unit="m">2.2</height>
</car>
select
<include refid="Base_Column_List" />
from XX
<![CDATA[ where XX > XX]]>
</select>
解析器
DOM
Document Object Model,文档对象模型,可修改XML, 使用简单。但是不使用于大XML文件读取,内存会急速增加。
SAX
Simple API for XML XML的简单API,可对大型XML进行筛选性的读取一部分,需要自己写解析器,使用较复杂。使用SAX解析不能进行XML修改。

