void __fastcall TFrmGenCode::XSLTxml1Click(TObject *Sender)
{
    // XSLT转换xml文件格式  #include <Xml.XMLIntf.hpp>

    _di_IXMLDocument xml;
    _di_IXMLDocument xsl; // Xml::Xmlintf::IXMLDocument
    _di_IXMLDocument outdoc;
    // Xml::Xmlintf::IXMLDocument *outdoc = NewXMLDocument();

    String f1, f2, f3;
    WideString rtext;
    UnicodeString ustr;
    f1 = "E:\\cjj\\CallFunLog\\TableClass.xml";
    f2 = "E:\\cjj\\CallFunLog\\TableClass.xsl";
    f3 = "c:\\kcode.html";

    xml = interface_cast<Xmlintf::IXMLDocument>(new TXMLDocument(NULL));
    xsl = interface_cast<Xmlintf::IXMLDocument>(new TXMLDocument(NULL));
    outdoc = interface_cast<Xmlintf::IXMLDocument>(new TXMLDocument(NULL));
    xml->LoadFromFile(f1); // LoadXMLData(f1);
    xsl->LoadFromFile(f2);

    xml->Node->TransformNode(xsl->DocumentElement, rtext);

    // err DocumentElement->TransformNode
    // xml->DocumentElement->TransformNode(xsl->DocumentElement, rtext);
    ustr = rtext;
    SynMemo1->Text = ustr;
    outdoc->LoadFromXML(ustr);
    outdoc->SaveToFile(f3);
    WebBrowser1->Navigate(f3);
    DeleteFileW(f3);
}

 写好xml数据和xsl格式就OK啦!

 

_di_IXMLDocument xml=NewXMLDocument();

xml->Active=false;

不能delete xml;报错。

posted on 2015-03-06 12:12  lypzxy  阅读(326)  评论(0编辑  收藏  举报