tinyxml动态库生成和使用「建议收藏」

tinyxml动态库生成和使用「建议收藏」1、xml默认是生成执行文件,要想生成动态库需要修改makefile从http://ncu.dl.sourceforge.net/sourceforge/tinyxml/tinyxml_2_4_0.tar.gz下载tinyxml,可以根据自己的需要,选择不同的版本。将tinyxml_2_4_0.tar.gz上传到主机,然后解压执行如下命令: tar-xzvftinyxml_2_

大家好,又见面了,我是你们的朋友全栈君。

1、xml默认是生成执行文件,要想生成动态库需要修改makefile

http://ncu.dl.sourceforge.net/sourceforge/tinyxml/tinyxml_2_4_0.tar.gz下载tinyxml,可以根据自己的需要,选择不同的版本。

将tinyxml_2_4_0.tar.gz上传到主机,然后解压执行如下命令:

 tar -xzvf tinyxml_2_4_0.tar.gz

成功之后,会在当前目录出现一个tinyxml目录,进入该目录cd tinyxml,然后进行编译,顺序执行如下命令:

cd tinyxml

make

在屏幕上会打印如下输出:

  1. [dev@localhost tinyxml]$ make  
  2. g++ -c -Wall -Wno-format -g -DDEBUG    tinyxml.cpp -o tinyxml.o  
  3. g++ -c -Wall -Wno-format -g -DDEBUG    tinyxmlparser.cpp -o tinyxmlparser.o  
  4. g++ -c -Wall -Wno-format -g -DDEBUG    xmltest.cpp -o xmltest.o  
  5. g++ -c -Wall -Wno-format -g -DDEBUG    tinyxmlerror.cpp -o tinyxmlerror.o  
  6. g++ -c -Wall -Wno-format -g -DDEBUG    tinystr.cpp -o tinystr.o  
  7. tinystr.cpp:38: warning: aggregate has a partly bracketed initializer  
  8. g++ -o xmltest -g tinyxml.o tinyxmlparser.o xmltest.o tinyxmlerror.o tinystr.o  

没有出现错误,表示编译完成,这时可以执行tinyxml自带的测试程序xmltest。

我直行xmltest之后,打印出一堆乱码,后来就没有管。自己写程序测试了。

 

为了使用tinyxml开发,使用方便,做了一些配置。

添加环境变量TINYXML_ROOT,编辑.bash_profile,添加如下内容:

  1. #############################################  
  2. #### for tinyxml  
  3. #############################################  
  4. export TINYXML_ROOT=$HOME/tinyxml  

把tinyxml包编译打包成一个连接库,方便开发,这就要修改tinyxml目录下的Makefile。

 

  1. #****************************************************************************  
  2. #  
  3. # Makefile for TinyXml test.  
  4. # Lee Thomason  
  5. # www.grinninglizard.com  
  6. #  
  7. # This is a GNU make (gmake) makefile  
  8. #****************************************************************************  
  9.  
  10. # DEBUG can be set to YES to include debugging info, or NO otherwise  
  11. DEBUG          := YES  
  12.  
  13. # PROFILE can be set to YES to include profiling info, or NO otherwise  
  14. PROFILE        := NO  
  15.  
  16. # TINYXML_USE_STL can be used to turn on STL support. NO, then STL  
  17. # will not be used. YES will include the STL files.  
  18. TINYXML_USE_STL := NO  
  19.  
  20. #****************************************************************************  
  21.   
  22. CC     := gcc  
  23. CXX    := g++  
  24. LD     := g++  
  25. AR     := ar rc  
  26. RANLIB := ranlib  
  27.   
  28. DEBUG_CFLAGS     := -Wall -Wno-format -g -DDEBUG  
  29. RELEASE_CFLAGS   := -Wall -Wno-unknown-pragmas -Wno-format -O3  
  30.   
  31. LIBS             :=  
  32.   
  33. DEBUG_CXXFLAGS   := ${DEBUG_CFLAGS}   
  34. RELEASE_CXXFLAGS := ${RELEASE_CFLAGS}  
  35.   
  36. DEBUG_LDFLAGS    := -g  
  37. RELEASE_LDFLAGS  :=  
  38.   
  39. ifeq (YES, ${DEBUG})  
  40.    CFLAGS       := ${DEBUG_CFLAGS}  
  41.    CXXFLAGS     := ${DEBUG_CXXFLAGS}  
  42.    LDFLAGS      := ${DEBUG_LDFLAGS}  
  43. else  
  44.    CFLAGS       := ${RELEASE_CFLAGS}  
  45.    CXXFLAGS     := ${RELEASE_CXXFLAGS}  
  46.    LDFLAGS      := ${RELEASE_LDFLAGS}  
  47. endif  
  48.   
  49. ifeq (YES, ${PROFILE})  
  50.    CFLAGS   := ${CFLAGS} -pg -O3  
  51.    CXXFLAGS := ${CXXFLAGS} -pg -O3  
  52.    LDFLAGS  := ${LDFLAGS} -pg  
  53. endif  
  54.  
  55. #****************************************************************************  
  56. # Preprocessor directives  
  57. #****************************************************************************  
  58.   
  59. ifeq (YES, ${TINYXML_USE_STL})  
  60.   DEFS := -DTIXML_USE_STL  
  61. else  
  62.   DEFS :=  
  63. endif  
  64.  
  65. #****************************************************************************  
  66. # Include paths  
  67. #****************************************************************************  
  68.  
  69. #INCS := -I/usr/include/g++-2 -I/usr/local/include  
  70. INCS :=  
  71.  
  72.  
  73. #****************************************************************************  
  74. # Makefile code common to all platforms  
  75. #****************************************************************************  
  76.   
  77. CFLAGS   := ${CFLAGS}   ${DEFS}  
  78. CXXFLAGS := ${CXXFLAGS} ${DEFS}  
  79.  
  80. #****************************************************************************  
  81. # Targets of the build  
  82. #****************************************************************************  
  83.   
  84. OUTPUT := xmltest   
  85. LIB := libtinyxml.so  
  86.   
  87. all: ${OUTPUT} ${LIB}  
  88.  
  89.  
  90. #****************************************************************************  
  91. # Source files  
  92. #****************************************************************************  
  93.   
  94. SRCS := tinyxml.cpp tinyxmlparser.cpp xmltest.cpp tinyxmlerror.cpp tinystr.cpp  
  95.  
  96. # Add on the sources for libraries  
  97. SRCS := ${SRCS}  
  98.   
  99. OBJS := $(addsuffix .o,$(basename ${SRCS}))  
  100. LIBOBJS := tinyxml.o tinyxmlparser.o tinyxmlerror.o tinystr.o  
  101.  
  102. #****************************************************************************  
  103. # Output  
  104. #****************************************************************************  
  105.   
  106. ${OUTPUT}: ${OBJS}  
  107.         ${LD} -o $@ ${LDFLAGS} ${OBJS} ${LIBS} ${EXTRA_LIBS}  
  108.   
  109. ${LIB}: ${LIBOBJS}  
  110.         ar -r $@ ${LIBOBJS}  
  111.  
  112.  
  113. #****************************************************************************  
  114. # common rules  
  115. #****************************************************************************  
  116.  
  117. # Rules for compiling source files to object files  
  118. %.o : %.cpp  
  119.         ${CXX} -c ${CXXFLAGS} ${INCS} $< -o $@  
  120.   
  121. %.o : %.c  
  122.         ${CC} -c ${CFLAGS} ${INCS} $< -o $@  
  123.   
  124. dist:  
  125.         bash makedistlinux  
  126.   
  127. clean:  
  128.         -rm -f core ${OBJS} ${OUTPUT} ${LIB} ${TEST}  
  129.   
  130. depend:  
  131.         #makedepend ${INCS} ${SRCS}  
  132.   
  133. tinyxml.o: tinyxml.h tinystr.h  
  134. tinyxmlparser.o: tinyxml.h tinystr.h  
  135. xmltest.o: tinyxml.h tinystr.h  
  136. tinyxmlerror.o: tinyxml.h tinystr.h  

在tinyxml目录下重新执行make,会看到多执行了一行命令:

ar -r libtinyxml.so tinyxml.o tinyxmlparser.o tinyxmlerror.o tinystr.o

生成了一个包libtinyxml.so,有了这个包,使用tinyxml开发的时候,在连接命令中加入这个包的连接,就可以正确地生成目标程序。


2、使用tinyxml库

TinyXML是一个开源的解析XML的解析库,能够用于C++,能够在Windows或Linux中编译。这个解析库的模型通过解析XML文件,然后在内存中生成DOM模型,从而让我们很方便的遍历这棵XML树。

    DOM模型即文档对象模型,是将整个文档分成多个元素(如书、章、节、段等),并利用树型结构表示这些元素之间的顺序关系以及嵌套包含关系。
    首先从网上下载TinyXML的库,文件夹的名字是TinyXpath,在工程里做如下配置:
    在附加包含路径里添加:你的tinyxpath路径/tinyxpath/include
    在附加库路径里添加:你的tinyxpath路径/tinyxpath/lib
    在对象/库路径里添加:tinyxpathd.lib,如果使用release版本,则是tinyxpath.lib。
    另外,由于我开发的项目是多线程的,所以设置了多线程的环境,因此使用TinyXML没有出现问题。本人将TinyXML写在一个单独的C++工程进行测试,发现如果不设置多线程的环境,会出现链接错误我觉得原因可能是TinyXML使用了多线程环境,因此需要设置

多线程的环境。在工程/设置下的C/C++选项卡中,选择Code Generation,在Use run-time library中选择Debug MultiThreaed DLL即可。
    本例的XML文件Students.xml如下:

id=”iframe_0.238658958169796″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.238658958169796′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 11px; height: 16px;”><Class name=
“计算机软件班”>

id=”iframe_0.4314071120123457″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.4314071120123457′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>    <Students>

id=”iframe_0.5366316319000168″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.5366316319000168′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>        <student name=
“张三” studentNo=
“13031001” sex=
“男” age=
“22”>

id=”iframe_0.21304391208801743″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.21304391208801743′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>            <phone>88208888</phone>

id=”iframe_0.9251619861410729″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.9251619861410729′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>            <address>西安市太白南路二号</address>

id=”iframe_0.6021517642700922″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.6021517642700922′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>        </student>

id=”iframe_0.6341668334925294″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.6341668334925294′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>        <student name=
“李四” studentNo=
“13031002” sex=
“男” age=
“20”>

id=”iframe_0.802585094038172″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.802585094038172′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>            <phone>88206666</phone>

id=”iframe_0.44781580335367255″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.44781580335367255′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>            <address>西安市光华路</address>

id=”iframe_0.11384552384977575″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.11384552384977575′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>        </student>

id=”iframe_0.05060587505102476″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.05060587505102476′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>    </Students>

id=”iframe_0.916137101333931″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.916137101333931′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”></Class>

    程序代码XmlParseExample.cpp如下所示:

id=”iframe_0.5045835055573049″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.5045835055573049′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>#include <iostream>

id=”iframe_0.12717277723937692″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.12717277723937692′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>#include <
string>

id=”iframe_0.7911499984094643″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.7911499984094643′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>#include <tinyxml.h>

id=”iframe_0.6797304277618614″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.6797304277618614′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>


  using std::
string;

id=”iframe_0.4726179124668808″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.4726179124668808′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>


  int main()

id=”iframe_0.8307900466320224″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.8307900466320224′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>{

id=”iframe_0.1861888369931608″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.1861888369931608′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>  TiXmlDocument* myDocument = 
new TiXmlDocument();

id=”iframe_0.8070116582035924″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.8070116582035924′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>  myDocument->LoadFile(
“Students.xml”);

id=”iframe_0.7752662136819903″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.7752662136819903′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>  TiXmlElement* rootElement = myDocument->RootElement();  
//Class

id=”iframe_0.12817875489448105″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.12817875489448105′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>  TiXmlElement* studentsElement = rootElement->FirstChildElement();  
//Students

id=”iframe_0.18624075806944407″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.18624075806944407′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>  TiXmlElement* studentElement = studentsElement->FirstChildElement();  
//Students

id=”iframe_0.2740520439978009″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.2740520439978009′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>  
while ( studentElement ) {

id=”iframe_0.07987582854164255″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.07987582854164255′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>    TiXmlAttribute* attributeOfStudent = studentElement->FirstAttribute();  
//获得student的name属性

id=”iframe_0.851699008283888″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.851699008283888′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>    
while ( attributeOfStudent ) {

id=”iframe_0.00541869841883047″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.00541869841883047′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>      std::cout << attributeOfStudent->Name() << 
” : “ << attributeOfStudent->Value() << std::endl;

id=”iframe_0.5832653685379883″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.5832653685379883′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>      attributeOfStudent = attributeOfStudent->Next();

id=”iframe_0.061893995195918095″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.061893995195918095′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>    }

id=”iframe_0.00529127955311548″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.00529127955311548′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>    TiXmlElement* phoneElement = studentElement->FirstChildElement();
//获得student的phone元素

id=”iframe_0.36240679789353725″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.36240679789353725′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>    std::cout << 
“phone” << 
” : “ << phoneElement->GetText() << std::endl;

id=”iframe_0.9596108977233886″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.9596108977233886′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>    TiXmlElement* addressElement = phoneElement->NextSiblingElement();

id=”iframe_0.8693341939749397″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.8693341939749397′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>    std::cout << 
“address” << 
” : “ << phoneElement->GetText() << std::endl;

id=”iframe_0.09740815378216272″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.09740815378216272′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>    studentElement = studentElement->NextSiblingElement();

id=”iframe_0.23872697428271672″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.23872697428271672′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>  }

id=”iframe_0.8990366175957798″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.8990366175957798′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>  
return 0;

id=”iframe_0.03892032775494392″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.03892032775494392′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>}

   
 程序运行结果如下:
name : 张三
studentNo : 13031001
sex : 男
age : 22
phone : 88208888
address : 88208888
name : 李四
studentNo : 13031002
sex : 男
age : 20
phone : 88206666
address : 88206666



    
本例中使用的是对xml文件进行解析,很容易掌握,但是很多开发人员不知道如何对xml 字符流(非xml文件)进行解析,我看了TinyXML提供的源代码,里面可以使用如下方法对xml流解析。对应于上例,代码如下:

id=”iframe_0.735328356988513″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.735328356988513′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>
string xmlString = 

id=”iframe_0.023006223477946897″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.023006223477946897′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>            “<Class name=\”计算机软件班\”>\

id=”iframe_0.5864910718611323″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.5864910718611323′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>              <Students>\

id=”iframe_0.3596549137063396″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.3596549137063396′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>                <student name=\”张三\” studentNo=\”13031001\” sex=\”男\” age=\”22\”>\

id=”iframe_0.9128635095195798″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.9128635095195798′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>                  <phone>88208888</phone>\

id=”iframe_0.2400037559929149″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.2400037559929149′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>                  <address>西安市太白南路二号</address>\

id=”iframe_0.8826393390392213″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.8826393390392213′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>                </student>\

id=”iframe_0.08245379558500332″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.08245379558500332′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>                <student name=\”李四\” studentNo=\”13031002\” sex=\”男\” age=\”20\”>\

id=”iframe_0.3244030647776621″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.3244030647776621′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>                  <phone>88206666</phone>\

id=”iframe_0.3931108914639201″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.3931108914639201′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>                  <address>西安市光华路</address>\

id=”iframe_0.9682242754411596″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.9682242754411596′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>                </student>\

id=”iframe_0.25672920789727693″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.25672920789727693′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>              </Students>\

id=”iframe_0.9453442512246908″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.9453442512246908′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>            </Class>”;

id=”iframe_0.9535319498883794″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.9535319498883794′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>  TiXmlDocument* myDocument = 
new TiXmlDocument();

id=”iframe_0.7544976750332633″ src=”data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://panpan.blog.51cto.com/images/editer/InBlock.gif?_=4995618%22%20style=%22border:none;max-width:1017px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById(‘img’);%20window.parent.postMessage(%7BiframeId:’iframe_0.7544976750332633′,width:img.width,height:img.height%7D,%20’http://www.cnblogs.com’);%7D%3C/script%3E” frameborder=”0″ scrolling=”no” style=”border-width: initial; border-style: none; width: 0px; height: 0px;”>  myDocument->Parse(xmlString.c_str());

   
 使用Parse函数就可以解析XML字符流了,这是很多开发者不太熟悉的情况。

    如果开发者开发特定应用,就可以使用上述类似方法,可能不需要完全处理每一个属性,比如可以对属性名进行判断,只处理自己需要的属性,或者自己需要的xml元素。还可以使用TinyXML的方法创建xml元素和xml属性,或者设置xml元素和属性对应的值,等等,如果读者想要类似的例子,可以留言写出。

     
下面介绍TinyXML的一些类。在TinyXML中,根据XML的各种元素来定义了一些类:

           TiXmlBase:整个TinyXML模型的基类。

TiXmlAttribute:对应于XML中的元素的属性。
TiXmlNode:对应于DOM结构中的节点。
TiXmlComment:对应于XML中的注释
TiXmlDeclaration:对应于XML中的申明部分,<?versiong=”1.0″ ?>。
TiXmlDocument:对应于XML的整个文档。
TiXmlElement:对应于XML的元素。
TiXmlText:对应于XML的文字部分
TiXmlUnknown:对应于XML的未知部分。 

        TiXmlHandler:定义了针对XML的一些操作。



3、linux中动态库的使用


编译生产libcac.so文件如下:
 gcc -shared -fPIC caculate.c -o libcac.so

编译生产可执行文件main如下:gcc main.c -o main -L ./ -lcac   (其中-L指明动态链接库的路径,-l后是链接库的名称,省略lib)
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/134043.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号