c语言解析XML字符串

前端之家收集整理的这篇文章主要介绍了c语言解析XML字符串前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<?xml versin='1.0' encoding='UTF-8'?><root><student><name>xioaming</name><age>20</age></student></root>

假设从环境变量中读取到的请求字符串为xmlreq,并将之存到内存;

xmlDocPtr doc;

int xmlreq_len = 0;

xmlNodePtr root,first_node,second_node;

char *first_label_name;

char *second_label_name;

char *sec_label_content = NULL;


doc = xmlReadMemory(xmlreq,xmlreq_len,NULL,0);

root = xmlDocGetRootElement(doc);

first_node = root->children;

first_label_name = first_node->name;

second_node = first_node->next;

second_label_name = second_node->name;

sec_label_content = xmlNodeGetContent(second_node);

猜你在找的XML相关文章