在delphi中使用xml文档有两种方法
使用xml broker, 是delphi 内置的。例:
unidad ShowXML;
interfaz
utiliza Clases HTTPApp Db DbClient Midas
Elementos intermedios XMLBrokr WebComp;
tipo
TCustomShowXMLButton = clase(TXMLButton IScriptComponent)
Protegido
Nombre del método XML: cadena;
{ Componente IScript }
procedimiento AddElements(AddIntf: IAddScriptElements);
función GetSubComponents: TObject;
{Implementación de IWebContent}
función ImplContent(Opciones: TWebContentOptions;
ParentLayout: TLayout): cadena; anular;
fin;
TShowXMLButton = clase(TCustomShowXMLButton)
público
constructor Crear(AOwner: TComponent); anular;
publicado
propiedad Aduana;
estilo de propiedad;
propiedad StyleRule;
título de propiedad;
propiedad XMLBroker;
propiedad XMLUseParent;
fin;
TShowDeltaButton = clase(TCustomShowXMLButton)
público
constructor Crear(AOwner: TComponent); anular;
publicado
propiedad Aduana;
estilo de propiedad;
propiedad StyleRule;
título de propiedad;
propiedad XMLBroker;
propiedad XMLUseParent;
fin;
implementación
utiliza sysutils MidProd;
cadena de recursos
sShowXML = 'Mostrar XML';
sShowDelta = 'Mostrar delta';
procedimiento TCustomShowXMLButton.AddElements(
AddIntf: IAddScriptElements);
comenzar
AddIntf.AddIncludeFile('xmlshow.js');
fin;
función TCustomShowXMLButton.GetSubComponents: TObject;
comenzar
Resultado := nulo;
fin;
función TCustomShowXMLButton.ImplContent(Opciones: TWebContentOptions;
ParentLayout: TLayout): cadena;
var
Atributos: cadena;
Intf: ILayoutWebContent;
FormVarName: cadena;
RowSetVarName: cadena;
comenzar
AddQuotedAttrib(Atributos 'NOMBRE' Nombre);
AddQuotedAttrib(Estilo 'ESTILO' de atributos);
AddQuotedAttrib (Regla de estilo de atributos 'CLASE');
AddQuotedAttrib(Atributos 'VALOR' Self.Caption);
AddCustomAttrib(Atributos personalizados);
si está asignado (XMLData.XMLBroker), entonces
comenzar
FormVarName := XMLData.XMLBroker.SubmitFormVarName;
RowSetVarName := XMLData.XMLBroker.RowSetVarName(nil); // fila conjunto de filas nombre var
fin;
si no (coNoScript en Options.Flags) entonces
Resultado :=
Formato(''#13#10
[Atributos RowSetVarName XMLMethodName sXMLReadyVar])
demás
Resultado :=
Formato(''#13#10
[Atributos]);
si está asignado (ParentLayout) y ParentLayout.GetInterface (ILayoutWebContent Intf) entonces
Resultado := Intf.LayoutButton(Resultado GetLayoutAttributes);
fin;
{ TShowXMLButton }
constructor TShowXMLButton.Create(AOwner: TComponent);
comenzar
heredado;
Título predeterminado: = sShowXML;
NombreMétodoXML := 'raíz';
fin;
{ TShowDeltaButton }
constructor TShowDeltaButton.Create(AOwner: TComponent);
comenzar
heredado;
Título predeterminado: = sShowDelta;
NombreMétodoXML := 'getDelta()';
fin;
Archivos adjuntos msxml.dll:
....
....
procedimiento TDHEDForm.OpenBtnClick (Remitente: TObject);
var
pVIn: OleVariante;
Mensaje: OleVariant;
comenzar
pVIn := '';
Mensaje: = Verdadero;
DHTMLEdit1.LoadDocument(mensaje pVIn);
fin;
procedimiento TDHEDForm.SaveBtnClick (Remitente: TObject);
var
vo vb : OleVariant;
comenzar
vo := DHTMLEdit1.CurrentDocumentPath;
si (vo <> '') entonces
comenzar
vb := falso;
fin
demás
comenzar
vo := '';
vb := verdadero;
fin;
DHTMLEdit1.SaveDocument(vo vb);
fin;
procedimiento TDHEDForm.SaveAsClick (Remitente: TObject);
var
vo vb : OleVariant;
comenzar
vo := '';
vb := verdadero;
DHTMLEdit1.SaveDocument(vo vb);
fin;
...
//本文为转贴,作者不详,仅供大家参考