Click here to Skip to main content
15,921,884 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: File Transfer Pin
Vasudevan Deepak Kumar2-Mar-06 0:09
Vasudevan Deepak Kumar2-Mar-06 0:09 
GeneralRe: File Transfer Pin
Coxianuk2-Mar-06 0:40
Coxianuk2-Mar-06 0:40 
QuestionPopup Blocker Detection Pin
Vasudevan Deepak Kumar1-Mar-06 23:08
Vasudevan Deepak Kumar1-Mar-06 23:08 
Questiontext nodes Pin
llp00na1-Mar-06 12:13
llp00na1-Mar-06 12:13 
AnswerRe: text nodes Pin
Stephen Hewitt1-Mar-06 23:05
Stephen Hewitt1-Mar-06 23:05 
GeneralRe: text nodes Pin
llp00na1-Mar-06 23:20
llp00na1-Mar-06 23:20 
GeneralRe: text nodes Pin
llp00na1-Mar-06 23:23
llp00na1-Mar-06 23:23 
GeneralRe: text nodes Pin
llp00na1-Mar-06 23:39
llp00na1-Mar-06 23:39 
GeneralRe: text nodes Pin
Stephen Hewitt2-Mar-06 0:21
Stephen Hewitt2-Mar-06 0:21 
GeneralRe: text nodes Pin
llp00na2-Mar-06 0:26
llp00na2-Mar-06 0:26 
GeneralRe: text nodes Pin
Stephen Hewitt2-Mar-06 0:42
Stephen Hewitt2-Mar-06 0:42 
GeneralRe: text nodes Pin
llp00na2-Mar-06 1:13
llp00na2-Mar-06 1:13 
GeneralRe: text nodes Pin
Stephen Hewitt2-Mar-06 1:42
Stephen Hewitt2-Mar-06 1:42 
GeneralRe: text nodes Pin
llp00na2-Mar-06 4:53
llp00na2-Mar-06 4:53 
GeneralRe: text nodes Pin
llp00na2-Mar-06 5:27
llp00na2-Mar-06 5:27 
GeneralRe: text nodes Pin
Stephen Hewitt2-Mar-06 11:26
Stephen Hewitt2-Mar-06 11:26 
GeneralRe: text nodes Pin
llp00na2-Mar-06 23:30
llp00na2-Mar-06 23:30 
GeneralRe: text nodes Pin
Stephen Hewitt3-Mar-06 0:42
Stephen Hewitt3-Mar-06 0:42 
GeneralRe: text nodes Pin
llp00na3-Mar-06 4:09
llp00na3-Mar-06 4:09 
GeneralRe: text nodes Pin
Stephen Hewitt3-Mar-06 19:18
Stephen Hewitt3-Mar-06 19:18 
GeneralRe: text nodes Pin
llp00na4-Mar-06 5:41
llp00na4-Mar-06 5:41 
GeneralRe: text nodes Pin
Stephen Hewitt4-Mar-06 15:00
Stephen Hewitt4-Mar-06 15:00 
GeneralRe: text nodes Pin
llp00na5-Mar-06 1:38
llp00na5-Mar-06 1:38 
GeneralRe: text nodes Pin
Stephen Hewitt4-Mar-06 15:56
Stephen Hewitt4-Mar-06 15:56 
Here's some code which doesn't do what you want, but contains all the elements you need. You should be able to alter it to suit your needs. It uses straight COM without any smart pointers. Normally I'd use ATL smart pointers but I thought this way it will work "out of the box", you can alter it use your favorite smart pointers. The code will be considerably smaller if you alter it to use some kind of smart pointer. Here goes:
-------------
void CMFCWebBrowserDlg::OnButton1()
{
IDispatch *pDisp = m_Browser.GetDocument();
if ( pDisp != NULL )
{
IHTMLDocument2 *pDoc2;
HRESULT hr = pDisp->QueryInterface(&pDoc2);
if ( SUCCEEDED(hr) )
{
ASSERT(pDoc2);

IHTMLElement *pBodyElement;
hr = pDoc2->get_body(&pBodyElement);
if ( SUCCEEDED(hr) && pBodyElement )
{
IHTMLDOMNode *pDOMNode;
hr = pBodyElement->QueryInterface(&pDOMNode);
if ( SUCCEEDED(hr) )
{
ASSERT(pDOMNode);

IDispatch *pChildrenDisp;
hr = pDOMNode->get_childNodes(&pChildrenDisp);
if ( SUCCEEDED(hr) )
{
ASSERT(pChildrenDisp);

IHTMLDOMChildrenCollection *pChildrenCollection;
hr = pChildrenDisp->QueryInterface(&pChildrenCollection);
if ( SUCCEEDED(hr) )
{
ASSERT(pChildrenCollection);

long NumItems;
if ( SUCCEEDED(pChildrenCollection->get_length(&NumItems)) )
{
for ( long i=0; i<NumItems; ++i )
{
IDispatch *pItemDisp;
hr = pChildrenCollection->item(i, &pItemDisp);
if ( SUCCEEDED(hr) && pItemDisp!=NULL )
{
// Is it a text node?
IHTMLDOMTextNode *pTextNode;
hr = pItemDisp->QueryInterface(&pTextNode);
if ( SUCCEEDED(hr) )
{
// It's a text node so get the text.
BSTR bstrText;
hr = pTextNode->get_data(&bstrText);
if ( SUCCEEDED(hr) )
{
MessageBoxW(m_hWnd, bstrText, L"Text node", MB_OK);

SysFreeString(bstrText);
}
}
else
{
// It's not a text node.
IHTMLElement *pElem;
hr = pItemDisp->QueryInterface(&pElem);
if ( SUCCEEDED(hr) )
{
ASSERT(pElem);

BSTR bstrOuter;
hr = pElem->get_outerHTML(&bstrOuter);
if ( SUCCEEDED(hr) )
{
MessageBoxW(m_hWnd, bstrOuter, L"Element", MB_OK);

SysFreeString(bstrOuter);
}

pElem->Release();
}
}

pItemDisp->Release();
}
}
}

pChildrenCollection->Release();
}

pChildrenDisp->Release();
}

pDOMNode->Release();
}

pBodyElement->Release();
}

pDoc2->Release();
}

pDisp->Release();
}
}

Steve
GeneralRe: text nodes Pin
llp00na5-Mar-06 6:28
llp00na5-Mar-06 6:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.