头文件 #include "mxml.h" (需要加载xml动态库)
<?xml version="1.0" encoding="utf-8"?>
<bookstore>
<book category="CHILDREN">
<title>Harry.Potter</title>
<author>JK.Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title>LearningXML</title>
<author>ErikT.Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
解析:
1、 FILE *fp = fopen(xml_file, "r"); //打开xml文件,注意文件路径与文件打开方式
2、 mxml_node_t *tree = mxmlLoadFile(NULL, fp, MXML_TEXT_CALLBACK); //获取xml文件指针
fclose(fp); //此处可以关闭文件
3、mxml_node_t *book = mxmlFindElement(pRoot, pRoot,"boo