網絡服務器軟件開發/中間件開發,關注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
搜索
積分與排名
積分 - 236283
排名 - 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腳本【轉】(15008)
2.?怪異的boost,fatal error LNK1104: 無法打開文件“libboost_system-vc80-mt-gd-1_35.lib”(11449)
3.?boost interprocess之message queue(7119)
4.?【ZT】ADSL大型技術專題(圖文)(6917)
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
閱讀(1210)
評論(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
大蕉久久伊人中文字幕
|
久久一区二区免费播放
|
久久综合综合久久综合
|
国产婷婷成人久久Av免费高清
|
久久亚洲sm情趣捆绑调教
|
中文精品99久久国产
|
人妻精品久久久久中文字幕一冢本
|
国产欧美久久一区二区
|
欧美精品国产综合久久
|
国产精品激情综合久久
|
色综合久久综合中文综合网
|
久久综合九色综合欧美就去吻
|
国产亚洲色婷婷久久99精品
|
久久亚洲AV无码精品色午夜
|
久久国产成人精品国产成人亚洲
|
狠狠色丁香久久婷婷综合_中
|
亚洲精品视频久久久
|
国产成人精品久久二区二区
|
国色天香久久久久久久小说
|
久久亚洲高清观看
|
亚洲中文字幕久久精品无码喷水
|
精品久久久久久无码人妻热
|
天天做夜夜做久久做狠狠
|
久久综合九色综合97_久久久
|
久久精品国产亚洲av麻豆蜜芽
|
国产一区二区精品久久凹凸
|
亚洲午夜久久久久妓女影院
|
香蕉久久AⅤ一区二区三区
|
精品视频久久久久
|
久久精品亚洲精品国产欧美
|
国产精品gz久久久
|
国产精品内射久久久久欢欢
|
国产99久久久久久免费看
|
一级做a爰片久久毛片人呢
|
色综合久久中文综合网
|
99久久免费国产精品
|
国产农村妇女毛片精品久久
|
国产福利电影一区二区三区久久老子无码午夜伦不
|
狠狠人妻久久久久久综合
|
伊人久久大香线蕉精品
|
国内精品久久久久久麻豆
|