XML解析器,自己加了点注释。留底
#include <iostream>
#include "1.h"
int main(int argc, char *argv[])
{
try
{
SXmlDOM dom;
//dom.parse("<?xml?><书店><书本 书名="VC++" 价格="50" 折扣="1"/><书本 书名="VB" 价格="50" 折扣="0.8"/><书本 书名="C#" 价格="50" 折扣="0.7">有源程序光盘</书本><挂历><年份>2006</年份><价格>50</价格></挂历></书店>")
dom.parseFile("test.xml");
//查询
SXmlElement& root = dom.root();
cout << "有" << root.count("书本") << "本书!"<< endl;
cout << "VB的价格:" << (int)root.item("书本", 1)["价格"] * (float)root.item("书本", 1)["折扣"] << endl;
cout << root.at(0).xml();
SXmlElement& gl = root.item("挂历");
cout << gl.item("年份").text() << endl;
//遍历
SXmlNodeList::iterator iter;
for(iter = root.begin(); iter!=root.end(); iter++)
cout << (*iter)->xml();
//赋值
root.item("书本", 1)["价格"] = 60;
root.item("书本", 1)["折扣"] = 0.5;
cout << "VB的价格:" << (int)root.item("书本", 1)["价格"] * (float)root.item("书本", 1)["折扣"] << e
相关文档:
data.xml
<?xml version="1.0" encoding="UTF-8"?>
<Items>
<Item ASIN="0446355453"
Author="Sidney Sheldon"
Manufacturer="Warner Books"
ProductGroup="Book"
Title="Master of the Game"/>
<Item ASIN=" ......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="fw_student">
<resultMap class="com.sias.Student" id="student">
<result column="name" property="na ......
1、导出到XMl select * from Brand for xml auto ,root('Brands')
<Brands>
<Brand BrandID="E584596D-4D66-4F2F-B6F7-71C3BEB4CA21" Name="inganico" />
<Brand BrandID="19B04451-DDC4-4CDF-BE30-CB4E703B27DA" Name="安付达" />
<Brand BrandID="3C6C8E12-7C4A-4F1 ......
在进行MIS系统开发过程中,从配置文件中读取配置信息是每一个系统必须具备的功能,例如,我们要配置读取数据库配置信息,包括驱动程序名、连接字符串,用户名,口令等信息,由于这些信息会随着用户的不同而发生改变,所以不能直接把参数写在程序中,将其写入配置文件,然后在应用程序中读取配置信息并加以使用,是一个成 ......