網絡服務器軟件開發/中間件開發,關注ACE/ICE/boost
C++博客
首頁
新隨筆
聯系
聚合
管理
152 Posts :: 3 Stories :: 172 Comments :: 0 Trackbacks
常用鏈接
我的隨筆
我的評論
我參與的隨筆
留言簿
(18)
給我留言
查看公開留言
查看私人留言
隨筆分類
ACE(12)
boost(6)
C++基礎(20)
CORBA(4)
Design Pattern(1)
ebook(1)
ICE(7)
java(1)
linux(28)
mysql(15)
PHP(1)
python(6)
RakNet(1)
SQLite
STL(1)
VC/MFC/.NET(4)
辦公技巧(5)
編碼知識(8)
創意&想法(2)
開發感想(12)
理財(2)
其它開源庫(13)
生活感想(23)
數據結構算法(1)
通信技術(8)
網絡服務器開發(9)
游戲開發(4)
隨筆檔案
2012年7月 (1)
2011年9月 (1)
2011年8月 (1)
2011年5月 (2)
2011年4月 (1)
2011年1月 (9)
2010年12月 (6)
2010年11月 (1)
2010年10月 (3)
2010年9月 (12)
2010年8月 (7)
2010年7月 (1)
2009年10月 (2)
2009年9月 (3)
2009年8月 (1)
2009年3月 (1)
2009年2月 (5)
2009年1月 (6)
2008年12月 (2)
2008年11月 (1)
2008年10月 (1)
2008年9月 (1)
2008年7月 (9)
2008年6月 (10)
2008年5月 (13)
2008年4月 (2)
2008年3月 (3)
2008年1月 (1)
2007年11月 (5)
2007年9月 (1)
2007年8月 (5)
2007年7月 (3)
2007年6月 (2)
2007年5月 (4)
2007年4月 (20)
2007年3月 (6)
文章分類
設計模式
文章檔案
2007年3月 (3)
好友博客
LOGOS
搜索
積分與排名
積分 - 236301
排名 - 107
最新評論
1.?re: C++實現的MD5算法
你這代碼功底也夠爛了,你多測試幾次,內存嘩嘩的流...
--熱心網頁
2.?re: std::queue的front的問題[未登錄]
在c++中int并不是類,沒有析構,是值拷貝。
你換std::string試試,準掛。
--星爺
3.?re: mysql下如何執行sql腳本【轉】[未登錄]
Thanks!
--me
4.?re: ldconfig幾個需要注意的地方 zhuan
學習了,收藏
--thebye85
5.?re: 體驗RakNet的RPC3
評論內容較長,點擊標題查看
--雅歌
閱讀排行榜
1.?mysql下如何執行sql腳本【轉】(15009)
2.?怪異的boost,fatal error LNK1104: 無法打開文件“libboost_system-vc80-mt-gd-1_35.lib”(11449)
3.?boost interprocess之message queue(7119)
4.?【ZT】ADSL大型技術專題(圖文)(6918)
5.?VOIP開源項目源碼地址(二) ---[voip涉及到的所有的資料]【轉帖】(5442)
評論排行榜
1.?Buffer類就應該簡單,直觀(16)
2.?怪異的boost,fatal error LNK1104: 無法打開文件“libboost_system-vc80-mt-gd-1_35.lib”(13)
3.?自己造的一個線程類(12)
4.?對基本類型的再包裝,方便了移植(12)
5.?游戲害慘了我多少同學(10)
tinyxml 的使用,轉
TinyXml是一個基于DOM模型的、非驗證的輕量級C++解釋器, 用來讀寫配置文件是最好的,可從
http://www.grinninglizard.com/tinyxml/index.html
這里下載。構建TinyXML 時可以選擇是否支持STL, 一般建議選擇支持STL。TinyXml的源碼包里提供了VC6的工程文件,直接用它就可以生成靜態庫。然后把tinyxml.h, tinystr.h和lib拷到你工程下, 就可以用了。要注意的是, 如果需要STL支持,在你的工程里要定義一個宏TIXML_USE_STL, 然后把下面代碼添加到你的代碼里, 這段是摘自TinyXML自帶的例子。
#ifdef TIXML_USE_STL
#include
<
iostream
>
#include
<
sstream
>
using
namespace
std;
#else
#include
<
stdio.h
>
#endif
#if
defined( WIN32 ) && defined( TUNE )
#include
<
crtdbg.h
>
_CrtMemState startMemState;
_CrtMemState endMemState;
#endif
我參考了網上的有關TinyXML的文章, 寫了一個讀寫XML的例子,代碼如下:
#include
"
tinyxml.h
"
#ifdef TIXML_USE_STL
#include
<
iostream
>
#include
<
sstream
>
using
namespace
std;
#else
#include
<
stdio.h
>
#endif
#if
defined( WIN32 ) && defined( TUNE )
#include
<
crtdbg.h
>
_CrtMemState startMemState;
_CrtMemState endMemState;
#endif
#pragma
comment(lib, "tinyxmld_STL.lib")
int
WriteXML() ;
int
ReadXML() ;
//
讀取內存里的一段XML
int
ReadXML2() ;
int
main(
int
argc,
char
*
argv[])
...
{
cout
<<
"
開始測試!
"
<<
endl;
WriteXML() ;
ReadXML() ;
ReadXML2() ;
cout
<<
"
結束測試!
"
<<
endl ;
return
0
;
}
int
WriteXML()
...
{
TiXmlDocument xmlDoc(
"
test.xml
"
);
//
建立一個XML文件
TiXmlDeclaration Declaration(
"
1.0
"
,
"
gb2312
"
,
"
yes
"
);
//
聲明XML的屬性
xmlDoc.InsertEndChild( Declaration );
//
寫入基本的XML頭結構
TiXmlNode
*
pNode
=
NULL;
TiXmlElement
*
pRootElm
=
NULL;
TiXmlElement
*
pChildeElm
=
NULL;
TiXmlElement
*
pItemElm
=
NULL;
TiXmlText
*
pText
=
NULL;
//
一個指向Text的指針
pText
=
new
TiXmlText(
"
good
"
) ;
pRootElm
=
new
TiXmlElement(
"
todo
"
);
pNode
=
xmlDoc.InsertEndChild(
*
pRootElm) ;
pRootElm
=
pNode
->
ToElement() ;
pChildeElm
=
new
TiXmlElement(
"
child1
"
) ;
pChildeElm
->
SetAttribute(
"
num
"
,
9
) ;
pNode
=
pRootElm
->
InsertEndChild(
*
pChildeElm) ;
TiXmlElement
*
pChildeElm1
=
NULL;
pChildeElm1
=
pNode
->
ToElement() ;
pChildeElm1
->
InsertEndChild(
*
pText) ;
delete pChildeElm ;
pChildeElm
=
NULL ;
pChildeElm
=
new
TiXmlElement(
"
child2
"
) ;
pChildeElm
->
SetAttribute(
"
num
"
,
10
) ;
pNode
=
pRootElm
->
InsertBeforeChild (pChildeElm1,
*
pChildeElm) ;
TiXmlElement
*
pChildeElm2
=
NULL;
pChildeElm2
=
pNode
->
ToElement() ;
pChildeElm2
->
InsertEndChild(
*
pText) ;
xmlDoc.Print() ;
xmlDoc.SaveFile();
//
把XML文件寫入硬盤
return
0
;
}
int
ReadXML()
...
{
cout
<<
endl ;
cout
<<
"
開始read XML
"
<<
endl ;
TiXmlDocument xmlDoc(
"
test.xml
"
);
xmlDoc.LoadFile() ;
TiXmlElement
*
xmlRootElement
=
0
;
TiXmlElement
*
xmlSubElement
=
0
;
TiXmlNode
*
pNode
=
NULL;
pNode
=
xmlDoc.FirstChild(
"
todo
"
) ;
xmlRootElement
=
pNode
->
ToElement() ;
if
(xmlRootElement)
...
{
pNode
=
xmlRootElement
->
FirstChild(
"
child1
"
) ;
xmlSubElement
=
pNode
->
ToElement() ;
cout
<<
xmlSubElement
->
Value()
<<
endl ;
cout
<<
xmlSubElement
->
Attribute(
"
num
"
)
<<
endl ;
cout
<<
xmlSubElement
->
GetText()
<<
endl ;
}
else
...
{
cout
<<
"
找不到根元素
"
<<
endl ;
}
cout
<<
"
結束read XML
"
<<
endl ;
return
0
;
}
int
ReadXML2()
...
{
cout
<<
endl ;
cout
<<
"
開始read XML
"
<<
endl ;
const
char
*
demoEnd
=
"
<?xml version="1.0" encoding="gb2312" standalone="yes" ?>
"
"
<todo>
"
"
<child2 num="10">good</child2>
"
"
<child1 num="9">good</child1>
"
"
</todo>
"
;
TiXmlDocument xmlDoc;
xmlDoc.Parse( demoEnd ) ;
TiXmlElement
*
xmlRootElement
=
0
;
TiXmlElement
*
xmlSubElement
=
0
;
TiXmlNode
*
pNode
=
NULL;
pNode
=
xmlDoc.FirstChild(
"
todo
"
) ;
xmlRootElement
=
pNode
->
ToElement() ;
if
(xmlRootElement)
...
{
pNode
=
xmlRootElement
->
FirstChild(
"
child1
"
) ;
xmlSubElement
=
pNode
->
ToElement() ;
cout
<<
xmlSubElement
->
Value()
<<
endl ;
cout
<<
xmlSubElement
->
Attribute(
"
num
"
)
<<
endl ;
cout
<<
xmlSubElement
->
GetText()
<<
endl ;
}
else
...
{
cout
<<
"
找不到根元素
"
<<
endl ;
}
cout
<<
"
結束read XML
"
<<
endl ;
return
0
;
posted on 2007-04-04 17:14
true
閱讀(1211)
評論(2)
編輯
收藏
引用
所屬分類:
其它開源庫
Feedback
#
re: tinyxml 的使用,轉
2007-05-14 08:03
zhangyingshi
突然問您個問題問題有些唐突,敬請您解答
關于tinyxml
在VC6.0中使用,源程序使用的是多線程release編譯所以我把tinyxml下載文件夾里的tinyxml_lib.dsp也用多線程release編譯生成了tinyxmld.lib,同兩個頭文件加入到程序中加入到程序中,函數調用都正常.但每次loadfile時候都失敗,跟蹤調試發現每次loadfile都探出一個對話框讓我指定vc60.pdb的位置,制定了幾次都不對
想問問您多線程編譯是不是這樣就可以?還是我使用tinyxml方法有問題
那個對話框是怎么回事。
該指定那個?
等待著您的回答。謝謝
回復
更多評論
#
re: tinyxml 的使用,轉
2007-05-14 11:55
eXile
作為一個測試程序, WriteXML 中對象的管理很混亂, 也許是lz不拘小節, 但會給人誤導...
回復
更多評論
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
【推薦】100%開源!大型工業跨平臺軟件C++源碼提供,建模,組態!
相關文章:
給ZThread提供一個patch
C++中使用C#的App.Config配置文件
讓人有點郁悶的PHP
國內一個不錯的開源鏡像
cmarkup【轉】
開源數據庫概覽【轉】
92個經典開源項目集錦(包括URL)【轉】
TinyXml總結
tinyxml 的使用,轉
tinyxml 使用
網站導航:
博客園
IT新聞
BlogJava
博問
Chat2DB
管理
Powered by:
C++博客
Copyright © true
91秦先生久久久久久久
|
无码人妻少妇久久中文字幕
|
偷偷做久久久久网站
|
97久久国产综合精品女不卡
|
久久A级毛片免费观看
|
99精品国产在热久久无毒不卡
|
国产三级久久久精品麻豆三级
|
亚洲午夜无码AV毛片久久
|
中文字幕无码精品亚洲资源网久久
|
亚洲愉拍99热成人精品热久久
|
成人久久精品一区二区三区
|
久久国产香蕉视频
|
久久久久国产精品熟女影院
|
蜜桃麻豆www久久
|
狠狠色噜噜色狠狠狠综合久久
|
久久99久久99小草精品免视看
|
久久男人中文字幕资源站
|
国产精品一区二区久久不卡
|
亚洲人成电影网站久久
|
四虎国产精品免费久久久
|
久久精品中文字幕一区
|
26uuu久久五月天
|
国产Av激情久久无码天堂
|
久久狠狠爱亚洲综合影院
|
激情五月综合综合久久69
|
99久久99久久久精品齐齐
|
亚洲精品乱码久久久久久自慰
|
亚洲国产天堂久久久久久
|
国产AV影片久久久久久
|
91精品国产高清91久久久久久
|
亚洲精品国产美女久久久
|
久久久无码精品亚洲日韩京东传媒
|
色综合久久综精品
|
成人妇女免费播放久久久
|
无码伊人66久久大杳蕉网站谷歌
|
久久久中文字幕日本
|
久久国产三级无码一区二区
|
激情久久久久久久久久
|
久久se精品一区二区影院
|
久久精品国产亚洲AV高清热
|
久久这里只有精品首页
|