svn上的minixml源碼下載。
svn co http://svn.msweet.org/mxml/tags/release-2.7/
按照下載回來的源代碼進行編譯和安裝。本教程只針對新手做一個引導,大神見笑了,可以直接繞道。願這個教程給你帶來幫助。
即:
./configure
make
make install
隨后就可以開始使用非常簡潔的並可以跨很多平台的minixml
更換平台只需要將xml庫使用不同的工具鏈重寫編譯一下即可啦。
開始開發的示例如下:
對應有個一minixml的中文說明手冊:MiniXML中文文檔.doc
http://wenku.baidu.com/view/25fd7d7f31b765ce050814f7.html
XML示例文件源
<?xml version="1.0" encoding="gb2312" ?> <note year="55" date="33" month="22"> <id>5000</id> <password>FE-D0-18-00</password> </note>
對應的解析代碼如下: 代碼很簡單放到你的工程里面跑一盤就十分清楚了。GoodLuck!
#include<mxml.h>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
int main()
{
FILE *fp;
mxml_node_t *tree,*node;
fp = fopen("debug_settings.xml", "r");
tree = mxmlLoadFile(NULL, fp,MXML_TEXT_CALLBACK);
fclose(fp);
mxml_node_t *id,*password;
node = mxmlFindElement(tree, tree, "note",NULL, NULL,MXML_DESCEND);
printf(" year:%s \n",mxmlElementGetAttr(node,"year"));
printf(" date:%s \n",mxmlElementGetAttr(node,"date"));
printf(" month:%s \n",mxmlElementGetAttr(node,"month"));
id = mxmlFindElement(node, tree, "id",NULL, NULL,MXML_DESCEND);
printf("[%s}\n",id->child->value.text.string);
password = mxmlFindElement(node, tree, "password",NULL, NULL,MXML_DESCEND);
printf("[%s]\n",password->child->value.text.string);
mxmlDelete(tree);
return 0 ;
}
