IXMLDOMDocument* xmlDoc; IXMLDOMNode* pNode; IXMLDOMNode* pNewNode; BSTR bstr = SysAllocString(L"book"); // Create a new node xmlDoc->createElement(bstr, &pNewNode); pNewNode->setAttribute(L"isbn", L"1234567890"); pNewNode->setAttribute(L"title", L"The Catcher in the Rye"); // Add the node to the document xmlDoc->get_documentElement(&pNode); pNode->appendChild(pNewNode);
IXMLDOMNode* pNode; BSTR bstr = SysAllocString(L"title"); BSTR bstrText; // Get the value of the title node xmlDoc->selectSingleNode(bstr, &pNode); pNode->get_text(&bstrText); std::wstring title = (wchar_t*)bstrText;These examples show how to use IXMLDOMNode in C++ to create and manipulate XML nodes. The library used here is MSXML.