gloox xml的解析模块
gloox自己实现了xml的解析模块,没有用到第三方的库(tinyXML,expat )
主要涉及的文件:
tag.h (tag.cpp)
taghandler.h
parser.h (parser.cpp)
1. Tag一个Tag就是一个XML元素
例如:
a.
<book kind='computer'>
<store id='23'/>
<author>
qiang
</author>
</book>
b. <book id='32'/>
c. <book>name1</book>
首先介绍一个概念: escape-string,何为escape-string?
在escape-string中:
'&'转换成&, '<'转换成<, '>'转换成>.
编码表如下:
//////////////////////////////////////////////////////////////////////////
// 编码表 (中间的空格去掉,这里只是为了方便显示):
// -------------------------------------------------------
// | 字符 | 十进制 | 十六进制 | THML字符集 | Unicode |
// -------------------------------------------------------
// | " 双引号 | & # 34; | & # x22; | " | \u0022 |
// -------------------------------------------------------
// | ' 单引号 | & # 39; | & # x27; | & apos; | \u0027 |
// -------------------------------------------------------
// | & 与 | & # 38; | & # x26; | & amp; | \u0026 |
// -------------------------------------------------------
// | < 小于号 | & # 60; | & # x3C; | & lt; | \u003c |
// -------------------------------------------------------
// | > 大于好 | & # 62; | & # x3E; | & gt; | \u003e |
// -------------------------------------------------------
gloox - APIs
Tag::escape() 功能: string -> escape-string
Tag::relax() 功能: escape-string -> string
主要成员变量:
attributes - 所有属性的list
name - 节点名字
cdata - 节点数据,例如<name>cdata</name>中的cda
相关文档:
标签:数据访问 ADO.NET
保存和加载XML文档 ......
参考:百度百科 http://baike.baidu.com/view/1027076.htm?fr=ala0
在JDK 6.0中基于StAX分析XML数据: http://hi.baidu.com/1shome/blog/item/5baaee01db2609051d958302.html
DOM、SAX
、DOM4J、JDOM、StAX生成XML
并返回XML字符串形式:http://dreams75.javaeye.com/blog/512319
STAX:Streaming API for XML (StAX)
......
using System.Xml;//头部加此命名空间
XmlDocument xd = new XmlDocument();//表示XML文档
XmlDeclaration xde;//表示 XML 声明节点:<?xml version='1.0'...?>
xde = xd.Cre ......
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml;
using FilmOnLine.Model;
namespace FilmOnLine.DAL
{
public static class FilmService
{
/// <summary>
/// 添加电影
/// </summary ......
XML (EXtensible Markup Language)
XML is a
cross-platform, software and hardware independent tool for transmitting
information.
Prolog
XML
Declaration
Processing
Instructions
DOCTYPE
Declaration
Elements
Attributes
XML
Comments
CDATA
Sections
Character
and Entity Refere ......