Exemplo n.º 1
0
/******************************************************************************
Function Name  :  FormatDOMDocument
Input(s)       :  MSXML2::IXMLDOMDocumentPtr pDoc
                  CString& omstrFilePath
Output         :  bool
Functionality  :  Formats the pDoc Pointer into File omStrFilePath
Member of      :  CTestSetupEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :
******************************************************************************/
BOOL CTestSetupEntity::FormatDOMDocument(MSXML2::IXMLDOMDocumentPtr pDoc, CString& omstrFilePath)
{
    //Referance Taken From Msdn
    MSXML2::ISAXXMLReaderPtr pSaxXmlReader = NULL;
    pSaxXmlReader.CreateInstance(L"Msxml2.SAXXMLReader");
    CComPtr<IStream> pStream;
    DWORD grfMode = STGM_WRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE;

    //W4 Removal
    if(SHCreateStreamOnFile ((LPCTSTR)omstrFilePath, grfMode, &pStream) == S_OK)
    {
        MSXML2::IMXWriterPtr pImxWriter;
        pImxWriter.CreateInstance (L"Msxml2.MXXMLWriter");
        pImxWriter->put_output (CComVariant(pStream));
        pSaxXmlReader->putContentHandler((MSXML2::ISAXContentHandlerPtr)pImxWriter);
        pSaxXmlReader->putErrorHandler((MSXML2::ISAXErrorHandlerPtr)pImxWriter);
        pSaxXmlReader->putDTDHandler((MSXML2::ISAXDTDHandlerPtr)pImxWriter);
        pImxWriter->put_byteOrderMark(VARIANT_TRUE);
        pImxWriter->put_indent(VARIANT_TRUE);
        //W4 Removal
        pSaxXmlReader->parse((_variant_t)(pDoc.GetInterfacePtr()));
        pImxWriter->flush ();
        return TRUE;
    }
    else
    {
        return FALSE;
    }
}
Exemplo n.º 2
0
	MSXML2::IXMLDOMDocument* CXmlDocumentWrapper::Clone()
	{
		if (!IsValid())
			return NULL;
		MSXML2::IXMLDOMDocumentPtr xmldoc;
		xmldoc.CreateInstance(MSXML2::CLSID_DOMDocument);
		_variant_t v(xmldoc.GetInterfacePtr());
		m_xmldoc->save(v);
		return xmldoc.Detach();
	}