在delphi中使用xml文档有两种方法
Para o corretor xml, para o Delphi, por exemplo:
unidade ShowXML;
interface
usa classes HTTPApp Db DbClient Midas
MidItems XMLBrokr WebComp;
tipo
TCustomShowXMLButton = classe(TXMLButton IScriptComponent)
Protegido
XMLMethodName: string;
{IScriptComponent}
procedimento AddElements(AddIntf: IAddScriptElements);
função GetSubComponents: TObject;
{Implementação IWebContent}
função ImplContent(Opções: TWebContentOptions;
ParentLayout: TLayout): string; substituir;
fim;
TShowXMLButton = classe(TCustomShowXMLButton)
público
construtor Criar (AOwner: TComponent); substituir;
publicado
propriedade personalizada;
estilo de propriedade;
propriedade StyleRule;
Legenda da propriedade;
propriedadeXMLBroker;
propriedade XMLUseParent;
fim;
TShowDeltaButton = classe(TCustomShowXMLButton)
público
construtor Criar (AOwner: TComponent); substituir;
publicado
propriedade personalizada;
estilo de propriedade;
propriedade StyleRule;
Legenda da propriedade;
propriedadeXMLBroker;
propriedade XMLUseParent;
fim;
implementação
usa sysutils MidProd;
cadeia de recursos
sShowXML = 'Mostrar XML';
sShowDelta = 'Mostrar Delta';
procedimento TCustomShowXMLButton.AddElements(
AddIntf: IAddScriptElements);
começar
AddIntf.AddIncludeFile('xmlshow.js');
fim;
função TCustomShowXMLButton.GetSubComponents: TObject;
começar
Resultado := nulo;
fim;
função TCustomShowXMLButton.ImplContent(Opções: TWebContentOptions;
ParentLayout: TLayout): string;
var
Atributos: string;
Intf: ILayoutWebContent;
FormVarNome: string;
RowSetVarName: string;
começar
AddQuotedAttrib(Nome 'NOME' dos atributos);
AddQuotedAttrib(Atributos 'Estilo' Estilo);
AddQuotedAttrib(Attrs 'CLASS' StyleRule);
AddQuotedAttrib(Attrs 'VALOR' Self.Caption);
AddCustomAttrib(Atributos personalizados);
se atribuído (XMLData.XMLBroker) então
começar
FormVarName := XMLData.XMLBroker.SubmitFormVarName;
RowSetVarName: = XMLData.XMLBroker.RowSetVarName (nil); // Linha linha definida var nome
fim;
se não (coNoScript em Options.Flags), então
Resultado :=
Formato(''#13#10
[Attrs RowSetVarName XMLMethodName sXMLReadyVar])
outro
Resultado :=
Formato(''#13#10
[Atributos]);
se Assigned(ParentLayout) e ParentLayout.GetInterface(ILayoutWebContent Intf) então
Resultado: = Intf.LayoutButton (Resultado GetLayoutAttributes);
fim;
{ TShowXMLButton }
construtor TShowXMLButton.Create(AOwner: TComponent);
começar
herdado;
DefaultCaption := sShowXML;
XMLMethodName := 'raiz';
fim;
{ TShowDeltaButton }
construtor TShowDeltaButton.Create(AOwner: TComponent);
começar
herdado;
DefaultCaption := sShowDelta;
XMLMethodName := 'getDelta()';
fim;
Aqui está o arquivo msxml.dll:
....
....
procedimento TDHEDForm.OpenBtnClick(Remetente: TObject);
var
pVIn: OleVariant;
Solicitação: OleVariant;
começar
pVIn := '';
Solicitação := Verdadeiro;
DHTMLEdit1.LoadDocument (prompt pVIn);
fim;
procedimento TDHEDForm.SaveBtnClick(Remetente: TObject);
var
vo vb : OleVariant;
começar
vo := DHTMLEdit1.CurrentDocumentPath;
se (vo <> '') então
começar
vb := falso;
fim
outro
começar
vo := '';
vb := verdadeiro;
fim;
DHTMLEdit1.SaveDocument(vo vb);
fim;
procedimento TDHEDForm.SaveAsClick(Remetente: TObject);
var
vo vb : OleVariant;
começar
vo := '';
vb := verdadeiro;
DHTMLEdit1.SaveDocument(vo vb);
fim;
...
//本文为转贴,作者不详,仅供大家参考