Skip to content

zinccyy/chtml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chtml

Small parser for html/xhtml in C.

Include a header

#include <chtml.h>

Initializing root element

chtml_element* root;
int return_value = chtml_parser_parse_file("test.html", &root);
if(return_value) {
	//... error while parsing
} else {
	// DOM is created
}
chtml_element_delete(&root); // removes the given element

Element properties

// example code for outputing root element name, content and first attribute key and value
#include <chtml.h>

int main(int argc, char** argv) 
{
	chtml_element* root;
	if(argc > 1) {
		if(!chtml_parser_parse_file(argv[1], &root)) {
			printf("Root element: \n");
			printf("\t name -> %s\n", root->tag);
			printf("\t content -> %s\n", root->content);
			printf("\t first attribute -> %s::'%s'\n", root->attributes[0]->key, root->attributes[0]->value);
		}
	}
	chtml_element_delete(&root);
	return 0;
}

About

Small parser for html/xhtml in C.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published