tags:

views:

227

answers:

5

How would I go about parsing HTML in C++ on my Webserver Application?

A: 

getc(), scanf ,cin


How about just a bit more detail. Are you writing an actual web server or an application on one.

rerun
I wrote an actual Webserver it gets basic HTML bautomatically by windows but does not know Div tags and what not
H4cKL0rD
A: 

It will mainly depend on what you want to do retrieve in your webpage. You can try boost::spirit to create your own parser. (Or a Yacc/Lex parser).

If your are looking for more simple information in the HTML page, getc may be good enough...

Phong
+1  A: 

libxml2 has a HTML parser. libxml++ is a wrapper for libxml2, but I'm not sure if it exposes the HTMLparser functionality.

Ignacio Vazquez-Abrams
A: 

Looks like QT Dom parser is the winner

http://stackoverflow.com/questions/489522/library-recommendation-c-html-parser

Joshua Smith
Assuming you're using Qt of course. Otherwise you're adding a lot of baggage to your app.
Ignacio Vazquez-Abrams
A: 

Hand parsing gets messy, even for relatively trivial cases.

Have you considered a Lexer/Parser, such as Flex/Bison? I highly recommend Antlr - and get AntlrWorks.

A picture is worth a thousand words, so this will tell you why - http://www.antlr.org/works/screenshots/editor.jpg

Mawg