Friday, December 28, 2012

GetChildElemetsByTagName VC++


///Get child elements by tag name
IHTMLElementCollection* CTest::GetChildElemetsByTagName(IHTMLElement* pElem,CString TagName)
{
IDispatch* pDisp = NULL;
IDispatch *pdispSpan;
IHTMLElement *peltSpan;

pElem->get_all(&pDisp);

IHTMLElementCollection* pFormColl = NULL;
HRESULT hr = pDisp->QueryInterface(IID_IHTMLElementCollection, (void**)&pFormColl);

pFormColl->tags(CComVariant(TagName.AllocSysString()),&pdispSpan);

CComQIPtr pEltColl2(pdispSpan);

return pEltColl2;
}


//Access this collection

void CTest::ChangeId(IHTMLElement* objElem, int Seq)
{

IHTMLElementCollection *pElemClc= GetChildElemetsByTagName(objElem,"p");

long lPCount;
BSTR tempBSTR;

pElemClc->get_length(&lPCount);
IHTMLElement *pElem;

for(int iIndex=0;iIndex {
//Get first header elem
CComPtr pdispSpan2;
pElemClc->item(CComVariant(iIndex), CComVariant(iIndex), &pdispSpan2);
pdispSpan2->QueryInterface(&pElem);

VARIANT objAttr;
pElem->getAttribute(_bstr_t("name"),1,&objAttr);
CString AttribVal(objAttr.bstrVal);

       }
}

Friday, December 21, 2012

Delete Html Tag


void CTest::DeleteTag(IHTMLElement* pElem,long &TotalElem)
{
pElem->put_outerHTML(L"");
//Since we are removing one elements
TotalElem=TotalElem-1;
}

Followers

Link