Skip to content

Instantly share code, notes, and snippets.

@tenderlove

tenderlove/test.c

Created Dec 5, 2009
Embed
What would you like to do?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libxml/parser.h>
void examine_nodes(char * xml) {
xmlDocPtr doc = xmlReadMemory(xml, strlen(xml), NULL, NULL,
XML_PARSE_NOBLANKS);
xmlNodePtr bbb_node = xmlDocGetRootElement(doc)->children;
xmlNodePtr child = bbb_node->children;
while(child) {
printf("%s: blank? %d\n", child->name, xmlIsBlankNode(child));
child = child->next;
}
}
int main(int argc, char *argv[]) {
char *xml_no_text = "<?xml version='1.0' encoding='UTF-8'?>" \
"<aaa><bbb> <ccc /> <ccc /> </bbb></aaa>";
char *xml_text = "<?xml version='1.0' encoding='UTF-8'?>" \
"<aaa><bbb>hello world <ccc /> <ccc /> </bbb></aaa>";
examine_nodes(xml_no_text);
printf("##############\n");
examine_nodes(xml_text);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment