
@H_404_8@
但是,我需要启用XSLT Javascript函数(< msxml:script>标记)和 – 经过大量谷歌搜索 – 这意味着我需要将IXMLDOMdocument2的AllowXsltScript属性设置为true.@H_404_8@
http://msdn.microsoft.com/en-us/library/windows/desktop/ms760290(v=vs.85).aspx@H_404_8@
我已经成功实现了这一点 – 但只能通过在msxmldom.pas中修改Delphi库函数CreateDOMdocument的源代码.@H_404_8@
@H_404_8@
function CreateDOMdocument: IXMLDOMdocument;var doc :IXMLDOMdocument2;begin doc := TryObjectCreate([CLASS_DOMdocument60,CLASS_DOMdocument40,CLASS_DOMdocument30,CLASS_DOMdocument26,msxml.CLASS_DOMdocument]) as IXMLDOMdocument2; if not Assigned(doc) then raise DOMException.Create(SMSDOMnotinstalled); doc.setProperty('AllowXsltScript',true); // Allow XSLT scripts!! Result := doc;end; 显然这远非令人满意 – 所以如何在不修改库代码的情况下访问IXMLDOMdocument2对象?@H_404_8@解决方法 您可以通过MSXMLDOMdocumentCreate变量覆盖create函数:
@H_404_8@
@H_404_8@
unit Unit27;interfaceuses xmldoc,xmlintf,msxml,msxmldom,Forms,SysUtils,ActiveX,ComObj,XmlDom,XmlConst,windows,Messages,Classes,Controls,StdCtrls;type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}function TryObjectCreate(const GuIDList: array of TGuID): IUnkNown;var I: Integer; Status: HResult;begin Status := S_OK; for I := Low(GuIDList) to High(GuIDList) do begin Status := CoCreateInstance(GuIDList[I],nil,CLSCTX_INPROC_SERVER or CLSCTX_LOCAL_SERVER,Idispatch,Result); if Status = S_OK then Exit; end; oleCheck(Status);end;function CreateDOMdocument2: IXMLDOMdocument;var Doc2 : IXMLDOMdocument2;begin Doc2 := TryObjectCreate([CLASS_DOMdocument60,msxml.CLASS_DOMdocument]) as IXMLDOMdocument2; if not Assigned(Doc2) then raise DOMException.Create(SMSDOMnotinstalled); Doc2.setProperty('AllowXsltScript',true); Result := Doc2;end;procedure TForm1.FormCreate(Sender: TObject);var Doc : IXMLdocument;begin Doc := TXMLdocument.Create(nil); Doc.LoadFromfile('c:\temp\test.xml');end;initialization MSXMLDOMdocumentCreate := CreateDOMdocument2;end. 总结 以上是内存溢出为你收集整理的delphi – 通过TXMLDocument访问IXMLDOMDocument2?全部内容,希望文章能够帮你解决delphi – 通过TXMLDocument访问IXMLDOMDocument2?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)