xml解析及编译汇总 valgrind检测内存泄露 http://blog.csdn.net/lifan5/article/details/8030285

前端之家收集整理的这篇文章主要介绍了xml解析及编译汇总 valgrind检测内存泄露 http://blog.csdn.net/lifan5/article/details/8030285前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

xml解析及编译汇总

分类c语言 1039人阅读 评论(0) 收藏 举报
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<stdlib.h>
  4. #include<libxml/xmlmemory.h>
  5. #include<libxml/parser.h>
  6. #include<libxml/tree.h>
  7. void
  8. get_connnectrequestUrl(char*docname){
  9. xmlDocPtrdoc;
  10. xmlNodePtrcur;
  11. doc=xmlParseFile(docname);
  12. if(doc==NULL){
  13. printf("Documentnotparsedsuccessfully.\n");
  14. return;
  15. }
  16. cur=xmlDocGetRootElement(doc);
  17. if(cur==NULL){
  18. printf("emptydocument\n");
  19. xmlFreeDoc(doc);
  20. if(xmlStrcmp(cur->name,(constxmlChar*)"Context")){
  21. printf("documentofthewrongtype,rootnode!=Context");
  22. xmlFreeDoc(doc);
  23. return;
  24. }
  25. cur=cur->xmlChildrenNode;
  26. while(cur!=NULL){
  27. xmlNodePtrcur2_tmp=cur;
  28. xmlChar*key;
  29. xmlChar*attr;
  30. charconnectrequestUrl[32];
  31. if((!xmlStrcmp(cur->name,153); font-weight:bold; background-color:inherit">constxmlChar*)"list"))){
  32. attr=xmlNodeListGetString(doc,cur->properties->xmlChildrenNode,1);
  33. if((!xmlStrcmp(attr,153); font-weight:bold; background-color:inherit">constxmlChar*)"rrm_cell"))){
  34. xmlFree(attr);
  35. cur=cur->xmlChildrenNode;
  36. constxmlChar*)"item"))){
  37. attr=xmlNodeListGetString(doc,1);
  38. constxmlChar*)"Cell_Map_s"))){
  39. xmlFree(attr);
  40. while(cur!=NULL){
  41. xmlNodePtrcur2_tmp=cur;
  42. constxmlChar*)"p"))){
  43. constxmlChar*)"Hnb_IP"))){
  44. printf("********************\n");
  45. key=xmlNodeListGetString(doc,cur->xmlChildrenNode,248)"> memcpy(connectrequestUrl,(constchar*)key,strlen((char*)key));
  46. connectrequestUrl[strlen((char*)key)]='\0';
  47. printf("theurlis:%s\n",connectrequestUrl);
  48. xmlFree(key);
  49. else{
  50. /*resetcul*/
  51. cur=cur2_tmp;
  52. cur=cur->next;
  53. /*RESETcur*/
  54. else{
  55. cur=cur2_tmp;
  56. cur=cur->next;
  57. intmain(void){
  58. while(1){
  59. get_connnectrequestUrl("config.xml");
  60. sleep(5);
  61. //return0;

编译:gcc -o testxml4 testxml4.c -I /usr/local/include/libxml2/ -L /usr/local/lib -lxml2

使用valgrind检测内存泄露的情况:valgrind--tool=memcheck--leak-check=full./testxml4

交叉编译:arm-none-linux-gnueabi-gcc -o testxml4 testxml4.c -I /usr/local/include/libxml2/ -L /usr/local/lib -lxml2

原文链接:https://www.f2er.com/xml/296220.html

猜你在找的XML相关文章