C tinyxml的編譯及簡單使用方法

2021-05-26 06:39:43 字數 1590 閱讀 7209

1、編譯tinyxml

tar -xzvf tinyxml_2_4_0.tar.gz

cd tinyxml

修改makefile,根據具體的開發板提供的gcc修改,如果需要編譯出動態庫,加上

lib := libtinyxml.so

all: $ $

libobjs := tinyxml.o tinyxmlparser.o tinyxmlerror.o tinystr.o

$ :$

ar -r $@ $,即可編譯自己開發板所需要的動態鏈結庫。

(在clean中加入$ $,make clean時將刪除動態庫和test輸出檔案。)

make後會產生乙個測試檔案,copy到開發板的檔案系統後,./xmltest,串列埠會輸入一系列pass,並且產生幾個xml檔案,表示成功

2、tiny的簡單使用

在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的一些操作。

例如:<?xml version="1.0" standalone=no>

go to the toy store!

do bills

整個物件樹:

tixmldocument "demo.xml"

tixmldeclaration "version=』1.0′" "standalone=no"

tixmlcomment " our to do list data"

tixmlelement "todo"

tixmlelement "item" attribtutes: priority = 1

tixmltext "go to the "

tixmlelement "bold"

tixmltext "toy store!"

tixmlelement "item" attributes: priority=2

tixmltext "do bills"

在tinyxml中,用firstchild("名字")查詢節點時,呼叫firstchild函式的節點與要查詢的節點必須成「父子關係」。

控制代碼想要健壯地讀取乙個xml文件,檢查方法呼叫後的返回值是否為null是很重要的。一種安全的檢錯實現可能會產生像這樣的**:

tixmlelement* root = document.firstchildelement( "document" );

if ( root )

void convertgbktoutf8(cstring& strgbk)

pjsip的編譯及簡單使用

2.編譯 目錄下的readme.txt檔案中有編譯說明,關於windows下的注意點如下 building win32 target with microsoft visual studio 新建乙個空檔案pjlib include pj config site.h後,編譯pjsua工程出現以下錯誤...

pjsip的編譯及簡單使用

2.編譯 目錄下的readme.txt檔案中有編譯說明,關於windows下的注意點如下 building win32 target with microsoft visual studio generally we can just do these steps 1.visual studio 6...

SDL編譯及簡單使用

型別 sdl windwoevent 視窗事件 sdl keyboardevent 鍵盤事件 sdl mousemotionevent 滑鼠事件 事件處理 sdl pollevent 輪訓 sdl waitevent 等待事件,超時機制 推薦使用 包含sdl標頭檔案 include 初始化sdl s...