mshtml

Started by
11 comments, last by willthiswork89 18 years, 7 months ago
im having so much trouble with parsing lightweight html its unbeleivable....nothing will compile..ivbe googled it and nothing will compile because i use bloodshed idecan sombody give me an example that compiles in bloodshed dev ide? just to parse basic html
Advertisement
Quote:Original post by willthiswork89
im having so much trouble with parsing lightweight html its unbeleivable....nothing will compile..ivbe googled it and nothing will compile because i use bloodshed idecan sombody give me an example that compiles in bloodshed dev ide? just to parse basic html


What exactly is it that you want to do ?

You want to parse the tags and put them in a tree ?
I teleported home one night; With Ron and Sid and Meg; Ron stole Meggie's heart away; And I got Sydney's leg. <> I'm blogging, emo style
<html>
<head>
<body bgcolor="black" text="white">
I Want To See this On My Screen!
</body>
</head>
</html>

i want to parse that and see it inside a window? not sure if it can be done because i havnt found many things on it.
What doesn't compile? Be a little more specific. Anyway, a HTML parser and renderer is a pretty large task.
Put the html in a text file and save it as .html or .htm ;)
C++ has no native parser/compiler/renderer for html...
Quote:Original post by willthiswork89
<html>
<head>
<body bgcolor="black" text="white">
I Want To See this On My Screen!
</body>
</head>
</html>

i want to parse that and see it inside a window? not sure if it can be done because i havnt found many things on it.


Parsing it and displaying it yourself is an incredibly tedious task. I would suggest you look into some sort of control for the platform you are developping on, or to find another way to solve your problem. If you are REALLY interested in this (remember that there have been several man-years devoted to this topic by big entities and that their offerings aren't even displaying everything according to the standard yet, your best bet is to visit W3C's website and start reading.
I teleported home one night; With Ron and Sid and Meg; Ron stole Meggie's heart away; And I got Sydney's leg. <> I'm blogging, emo style
i know its easy for .net to do this...but i didnt know it was harder for c++....thanks though. I am making a hack for a game, it requires and html page....is there even a way to open an html file up inside of the exe?
http://www.codeproject.com/internet/parse_html.asp

heres a code...i get about 1,000,000,000 errors

Quote:#include <windows.h>
#include <mshtml.h>

OLECHAR szHTML[] = OLESTR("<HTML><BODY>Hello World!</BODY></HTML>");

int __stdcall WinMain(HINSTANCE hInst,
HINSTANCE hPrev,
LPSTR lpCmdLine,
int nShowCmd)
{
IHTMLDocument2 *pDoc = NULL;

CoInitialize(NULL);

CoCreateInstance(CLSID_HTMLDocument,
NULL,
CLSCTX_INPROC_SERVER,
IID_IHTMLDocument2,
(LPVOID *) &pDoc);

if (pDoc)
{
IPersistStreamInit *pPersist = NULL;

pDoc->QueryInterface(IID_IPersistStreamInit,
(LPVOID *) &pPersist);

if (pPersist)
{
IMarkupServices *pMS = NULL;

pPersist->InitNew();
pPersist->Release();

pDoc->QueryInterface(IID_IMarkupServices,
(LPVOID *) &pMS);

if (pMS)
{
IMarkupContainer *pMC = NULL;
IMarkupPointer *pMkStart = NULL;
IMarkupPointer *pMkFinish = NULL;

pMS->CreateMarkupPointer(&pMkStart);
pMS->CreateMarkupPointer(&pMkFinish);

pMS->ParseString(szHTML,
0,
&pMC,
pMkStart,
pMkFinish);

if (pMC)
{
IHTMLDocument2 *pNewDoc = NULL;

pMC->QueryInterface(IID_IHTMLDocument,
(LPVOID *) &pNewDoc);

if (pNewDoc)
{
// do anything with pNewDoc, in this case
// get the body innerText.

IHTMLElement *pBody;
pNewDoc-gt;get_body(&pBody);

if (pBody)
{
BSTR strText;

pBody->get_innerText(&strText);
pBody->Release();

SysFreeString(strText);
}

pNewDoc->Release();
}

pMC->Release();
}

if (pMkStart)
pMkStart->Release();

if (pMkFinish)
pMkFinish->Release();

pMS->Release();
}
}

pDoc->Release();
}

CoUninitialize();

return TRUE;
}

Quote:Original post by willthiswork89
http://www.codeproject.com/internet/parse_html.asp

heres a code...i get about 1,000,000,000 errors

Post the first couple of errors.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
15 C:\Dev-Cpp\Untitled1.cpp `CLSID_HTMLDocument' undeclared (first use this function)

23 C:\Dev-Cpp\Untitled1.cpp `IPersistStreamInit' undeclared (first use this function)

23 C:\Dev-Cpp\Untitled1.cpp `pPersist' undeclared (first use this function)

30 C:\Dev-Cpp\Untitled1.cpp `IMarkupServices' undeclared (first use this function)

30 C:\Dev-Cpp\Untitled1.cpp `pMS' undeclared (first use this function)

35 C:\Dev-Cpp\Untitled1.cpp `IID_IMarkupServices' undeclared (first use this function)

40 C:\Dev-Cpp\Untitled1.cpp `IMarkupContainer' undeclared (first use this function)

66 C:\Dev-Cpp\Untitled1.cpp `get_body' undeclared (first use this function)


just about every function in there
40 C:\Dev-Cpp\Untitled1.cpp `pMC' undeclared (first use this function)

This topic is closed to new replies.

Advertisement