tinyxml:快速入门----一个官方带说明示例的翻译
来源:互联网 发布:淘宝店铺活动怎么参加 编辑:程序博客网 时间:2024/05/16 18:33
转自Tinyxml主页上的一部分:
How TinyXML works.
TinyXML如何工作的
An example is probably the best way to go. Take:
例子是最好的入门办法。例如:
<?xml version="1.0" standalone=no><!-- Our to do list data --><ToDo><Item priority="1"> Go to the <bold>Toy store!</bold></Item><Item priority="2"> Do bills</Item></ToDo>
Its not much of a To Do list, but it will do. To read this file (say "demo.xml") you would create a document, and parse it in:
这并不是一个很好的To Do清单,但用来示例足够了。读取这个文件(且称为"demo.xml"),你需要创建一个document,然后用它来解析:
TiXmlDocument doc( "demo.xml" );doc.LoadFile();And its ready to go. Now lets look at some lines and how they relate to the DOM.
这样就准备好了。现在来看看一些代码,看他们如何跟DOM联系起来。
<?xml version="1.0" standalone=no>
The first line is a declaration, and gets turned into theTiXmlDeclarationclass. It will be the first child of the document node.
第一行是一个声明,生成TiXmlDeclaration对象。这是document的第一个孩子。
This is the only directive/special tag parsed by TinyXML. Generally directive tags are stored inTiXmlUnknownso the commands wont be lost when it is saved back to disk.
这是TinyXML解析的唯一一个directive tag。其他的directive tag存储在TiXmlUnknown,所以当他们存储到磁盘时,不会丢失。
<!-- Our to do list data -->
A comment. Will become aTiXmlCommentobject.
这是注释。生成TiXmlComment对象。
<ToDo>
The "ToDo" tag defines aTiXmlElementobject. This one does not have any attributes, but does contain 2 other elements.
To Do tag生成TiXmlElement对象。这个tag没有包含任何属性(attribute),但它包括两个元素(element)
<Item priority="1">
Creates anotherTiXmlElementwhich is a child of the "ToDo" element. This element has 1 attribute, with the name "priority" and the value "1".
这是TiXmlElement元素,也是To Do元素的一个孩子。这个元素有一个属性,name是"priority",值是"1"。
Go to the
A TiXmlText. This is a leaf node and cannot contain other nodes. It is a child of the "Item"TiXmlElement.
这是TiXmlText对象,这是一个叶节点,不包括其他子节点。这是"Item"的孩子。
<bold>
Another TiXmlElement, this one a child of the "Item" element.
另一个TiXmlElement元素,是"item"的子节点
Etc.
等等。
Looking at the entire object tree, you end up with:
看看完整的对象树,你将得到:
TiXmlDocument"demo.xml"TiXmlDeclaration"version='1.0'" "standalone=no"TiXmlComment" Our to do list data"TiXmlElement"ToDo"TiXmlElement"Item" Attribtutes: priority = 1TiXmlText"Go to the "TiXmlElement"bold"TiXmlText"Toy store!"TiXmlElement"Item" Attributes: priority=2TiXmlText"Do bills"
0 0
- tinyxml:快速入门----一个官方带说明示例的翻译
- 【Spark1.6官方翻译】Spark快速入门
- TinyXml快速入门
- 转:TinyXml快速入门
- tinyxml快速入门3
- TinyXml快速入门(一)
- TinyXml快速入门2
- TinyXml 快速入门三
- TinyXml快速入门
- TinyXml快速入门
- TinyXml快速入门
- TinyXml快速入门
- TinyXml快速入门
- TinyXml快速入门(一)
- TinyXml快速入门(二)
- TinyXml快速入门(三)
- TinyXml快速入门(一)
- TinyXml快速入门(二)
- C_WINAPI学习笔记
- 彻底卸载oracle11g
- 真机调试问题,Camera应用
- ibus五笔快捷键 繁简 单字 词组切换
- ios开发 - 使用CocoaPods管理类库
- tinyxml:快速入门----一个官方带说明示例的翻译
- Myeclipse.10 破解
- Java学习第11-12天:多线程
- java中随机类 Random实现方法
- review
- [MDIT每天一小时]2014年Android系统就业前景浅析
- HDU 3518 Boring counting
- 在Eclipse中使用Maven构建Spring项目
- First Missing Positive