Skip to content

Instantly share code, notes, and snippets.

@porterjamesj
Created May 3, 2014 01:52
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 porterjamesj/23e64cb2b9165b663fe4 to your computer and use it in GitHub Desktop.
Save porterjamesj/23e64cb2b9165b663fe4 to your computer and use it in GitHub Desktop.
just a small example of using google's gumbo for html parsing
#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