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示例文件源:
1 <?xml version="1.0" encoding="gb2312" ?>
2 <note year="55" date="33" month="22">
3 <id>5000</id>
4 <password>FE-D0-18-00</password>
5 </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 ;
}
转自:https://www.cnblogs.com/dyllove98/archive/2013/07/24/3212538.html