Created
May 3, 2014 01:52
-
-
Save porterjamesj/23e64cb2b9165b663fe4 to your computer and use it in GitHub Desktop.
just a small example of using google's gumbo for html parsing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "gumbo.h" | |
int main() { | |
GumboOutput* output = gumbo_parse("<h1>Hello, World!</h1>"); | |
// Gumbo inserts all the html, body, etc. | |
GumboNode *html = output->root; | |
GumboNode *body = (GumboNode *) html->v.element.children.data[1]; | |
GumboNode *header = (GumboNode *) body->v.element.children.data[0]; | |
GumboNode *text = (GumboNode *) header->v.element.children.data[0]; | |
printf("%s\n", text->v.text.text); // "Hello, World!" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment