//get parent node
IHTMLDOMNode* parent;
ielem->QueryInterface(IID_IHTMLDOMNode, (void**)&parent);
//get child node
IHTMLElement* child_element;
doc2->createElement(L"a", &child_element);
IHTMLDOMNode* child_node;
child_element->QueryInterface(IID_IHTMLDOMNode, (void**)&child_element);
//Create Value
VARIANT value;
value.vt = VT_BSTR;
value.bstrVal = L"TEST";
//set value
child_node->put_nodeValue(value);
//append child
parent->appendChild(child_node, &child_node);
我尝试的另一种方式是:
//initialize
IHTMLElement* element;
BSTR* innerhtml;
ielem->QueryInterface(IID_IHTMLElement, (void**)&element);
//overwrite the content
element->put_innerHTML(L"<a href=\"http://www.google.de\">testytest</a>");
element->get_innerHTML(innerhtml);
//check for success
MessageBox(0, *innerhtml, L"Titel", 0);
delete innerhtml;