Skip to content

cactoes/cpp-html-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTML Parser

A simple html parser written in c++

including this project

add_subdirectory(PATH_TO_THIS_LIBRARY)
# ... add_executable or simmilair
target_link_libraries(${PROJECT_NAME} PRIVATE cpp-html-parser)

example

#include <htmlparser.hpp>

int main () {
    using namespace parser;

    // parse the html wstring
    HTMLElement document = parseHTML("<h1>Hello</h1>");

    // print the h1 tag
    std::cout << document.children.at(0)->tag << "\n";

    return 0;
}

functions

constructor

only needs a tagname to create the element

HTMLElement::HTMLElement(const std::string& tag);

GetElementById

returns an optional pointer to the element with the specified id

std::optional<HTMLElement*> HTMLElement::GetElementById(const std::string& idName);

GetElementsByClassName

returns a list of element pointers which include the specified class name

std::vector<HTMLElement*> HTMLElement::GetElementsByClassName(const std::string& className);

GetElementsByTagName

returns a list of element pointers which include the specified tag name

std::vector<HTMLElement*> HTMLElement::GetElementsByTagName(const std::string& tagName);

contributors

license

MIT

About

A simple html parser written in c++

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published