Hi
I'm using IHTMLdocument2 to create Element
This is my code:
IHTMLdocument2 pDoc2;//it is initialized in ma code
BSTR eTag = SysAllocString(L"TR");
IHTMLElement *pTRElmt = NULL;
hr = pDoc2->createElement(eTag,&pTRElmt);
if(FAILED(hr))
return hr;
IHTMLDOMNode *pTRNode = NULL;
hr = pTRElmt->QueryInterface(IID_IHTMLDOMNode, (void **)&pTRNode);
if(FAILED(hr))
return hr;
// create TD node
IHTMLElement *pTDElmt = NULL;
hr = pDoc2->createElement(L"TD",&pTDElmt);
if(FAILED(hr))
return hr;
IHTMLDOMNode *pTDNode = NULL;
hr = pTDElmt->QueryInterface(IID_IHTMLDOMNode,(void **)&pTDNode);
if(FAILED(hr))
return hr;
IHTMLDOMNode *pRefNode = NULL;
hr = pTRNode->appendChild(pTDNode,&pRefNode);
if(FAILED(hr))
return hr;
// create TEXT Node
IHTMLDOMNode *pTextNode = NULL;
hr = pDoc3->createTextNode(L"madhu", &pTextNode);
if(FAILED(hr))
return hr;
IHTMLDOMNode *pRefNod = NULL;
hr = pTDNode->appendChild(pTextNode,&pRefNod);
if(FAILED(hr))
return hr;
//********* setting attributes for <tr>
/*
VARIANT bgclor;
bgclor.vt = VT_I4;
bgclor.lVal =0xC0C0C0;
hr = newElem->setAttribute(L"bgcolor",bgclor,1);
if(FAILED(hr))
return hr;
VARIANT style;
style.vt = VT_BSTR;
style.bstrVal = SysAllocString(L"display: table-row");
hr = newElem->setAttribute(L"style",style,1);
if(FAILED(hr))
return hr;
VARIANT id;
id.vt = VT_BSTR;
id.bstrVal = SysAllocString(L"AttrRowMiddleName");
hr = newElem->setAttribute(L"id",id,1);
if(FAILED(hr))
return hr;
*/
//create <td> for row <tr>
/*
VARIANT Name;
Name.vt = VT_BSTR;
Name.bstrVal = SysAllocString(L"MiddleName");
hr = newElem->setAttribute(L"name",Name,1);
if(FAILED(hr))
return hr;
VARIANT Type;
Type.vt = VT_BSTR;
Type.bstrVal = SysAllocString(L"text");
hr = newElem->setAttribute(L"type",Type,1);
if(FAILED(hr))
return hr;
VARIANT Value;
Value.vt = VT_BSTR;
Value.bstrVal = SysAllocString(L"button");
hr = newElem->setAttribute(L"value",Value,1);
if(FAILED(hr))
return hr;
*/
//IHTMLDOMNode *pReturn = NULL;
//hr = pParentNode->replaceChild(pdn,pFirstchild,&pReturn);
//if(FAILED(hr))
// return hr;
VARIANT refNode;
refNode.vt = VT_DISPATCH;
refNode.pdispVal = pDomNode;
IHTMLDOMNode *pREfTochild = NULL;
hr = pParentNode->insertBefore(pTRNode,refNode,&pREfTochild);
if(FAILED(hr))
return hr;
This is inserting something but not visible and inserting as and when tr tag comes
I even tried with clone but same problem.
pls anybody give right code for this