Create XML File
-
I am writing the following code for creating the XML file. HRESULT hr; IXMLDOMDocumentPtr pXMLDoc = NULL; CoInitialize(NULL); hr=pXMLDoc.CreateInstance("msxml2.domdocument"); IXMLDOMNodePtr pRootNode= NULL; IXMLDOMNodePtr pRecNode= NULL; IXMLDOMNodePtr pRecNode1= NULL; IXMLDOMElementPtr pElement=NULL; _variant_t varNodeType((short)MSXML2::NODE_ELEMENT); hr= pXMLDoc->createNode(varNodeType, _T("RTCS"), _T("Remote Target Control System"),&pRootNode); hr=pXMLDoc->createElement(_T("Connection"),&pElement); IXMLDOMAttributePtr pRecIdAttr = NULL; IXMLDOMNamedNodeMapPtr pattributeMap; hr=pXMLDoc->createAttribute(_T("connect"),&pRecIdAttr); hr=pRecIdAttr->put_nodeTypedValue(_variant_t(_T("connect_val"))); hr=pElement->get_attributes(&pattributeMap); hr=pattributeMap->setNamedItem(pRecIdAttr,&pRecNode); hr=pXMLDoc->appendChild(pRootNode,&pRecNode); but i am not able to see the child node created in the xml file.Only root node is created: The xml file i want to create is: ?xml version="1.0"?>