CoInitialize(NULL);
IXMLDOMDocument2Ptr DOMDocxml;
IXMLDOMDocument2Ptr DOMDocxsl;
IXSLTemplatePtr templateXsl;
IXSLProcessorPtr processorptr;
//Create a DOMDocument object.
DOMDocxml = CoFreeThreadedDOMDocument40::Create();
if(DOMDocxml.IsBound())
{
DOMDocxml->async = (TOLEBOOL)false;
TOLEBOOL test = DOMDocxml->load(TVariantInParam(WideString("MyXml.XML").Detach(), true));
if((bool)test == true)
{
//Create a DOMDocument object.
DOMDocxsl = CoFreeThreadedDOMDocument40::Create();
//define the DOM document content.
if(DOMDocxsl.IsBound())
{
DOMDocxsl->async = (TOLEBOOL)false;
//smartpointerDOMDocxsd->validateOnParse = (TOLEBOOL)false;
TOLEBOOL test = DOMDocxsl->load(TVariantInParam(WideString("MyXls.xsl").Detach(), true));
if((bool)test == true)
{
templateXsl = CoXSLTemplate40::Create();
if (templateXsl.IsBound() == true)
{
templateXsl->stylesheet = DOMDocxsl;
templateXsl->createProcessor((IXSLProcessorPtr*)&processorptr);
if (processorptr.IsBound () == true)
{
processorptr->set_input(TVariantInParam( (IUnknown*)DOMDocxml));
TOLEBOOL toto = processorptr->transform ();
if ((bool)toto == true)
{
TVariant toto = processorptr->get_output ();
AnsiString str = toto;
AnsiString htmlFile = "toto.html";
TStringList* p = new TStringList();
p->Add(str);
p->SaveToFile ("myHtml.html");
}
}
}
}
}
}
}
CoUninitialize();
Partager