Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created December 5, 2009 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenderlove/249807 to your computer and use it in GitHub Desktop.
Save tenderlove/249807 to your computer and use it in GitHub Desktop.
#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