I think the best way to explain a library is by using an example:
~~~~~~~~
using namespace std;
const string page =
"<html>"
" <head>"
"
Here I forgot the closing tag
"And here I used the wrong closing type"
" "
"
Very special characters: <![CDATA[<>&!]]>
new line
This should be displayed inline.
"bool checkElement(const HTMLelement &e)
{
if(e.name == "p")return true;
return false;
}
int main(int argc, char **args)
{
HTMLparser p;
HTMLelement e;
p.parse(page, e);
//getFormattedString removes all the tags //And represents the page in pure text cout<<e.getFormattedString()<<endl; //It is also possible to print only certain elements cout<<e.getFormattedString(&checkElement)<<endl; cout<<e.createHTML()<<endl;
}
~~~~~~
~~~~~~~
Testpage
Big title
Here I forgot the closing tag
And here I used the wrong closing type
Very special characters: <>&!
new line
This should be displayed inline.
Here I forgot the
And here I used the wrong closing type
Very special characters: <>&!
new line
should be displayed inline.
<html> <head>
Here I forgot the closing tag
And here I used the wrong closing type
Very special characters: <![CDATA[<>&!]]>
new line
This should be displayed inline.
</body></html>If you look at the Header file htmlelement.h you can see that it basically provides five properties:
<div\>
<a\>
<script\>
<h1\>
...<a href=".."\>
--> metaData would contain the href.