Les fichiers XML de Delphi
Un courtier XML, par Delphi 内置的。例 :
unité ShowXML ;
interface
utilise les classes HTTPApp Db DbClient Midas
Éléments intermédiaires XMLBrokr WebComp ;
taper
TCustomShowXMLButton = classe (TXMLButton IScriptComponent)
Protégé
XMLMethodName : chaîne ;
{ Composant IScript }
procédure AddElements(AddIntf : IAddScriptElements);
fonction GetSubComponents : TObject ;
{ Implémentation d'IWebContent }
fonction ImplContent(Options : TWebContentOptions ;
ParentLayout : TLayout) : chaîne ; outrepasser;
fin;
TShowXMLButton = classe (TCustomShowXMLButton)
publique
constructeur Create (AOwner : TComponent); outrepasser;
publié
propriété Coutume ;
Style de propriété ;
propriété StyleRule ;
Légende de la propriété ;
propriété XMLBroker ;
propriété XMLUseParent ;
fin;
TShowDeltaButton = classe (TCustomShowXMLButton)
publique
constructeur Create (AOwner : TComponent); outrepasser;
publié
propriété Coutume ;
Style de propriété ;
propriété StyleRule ;
Légende de la propriété ;
propriété XMLBroker ;
propriété XMLUseParent ;
fin;
mise en œuvre
utilise sysutils MidProd ;
chaîne de ressources
sShowXML = 'Afficher XML';
sShowDelta = 'Afficher Delta';
procédure TCustomShowXMLButton.AddElements(
AddIntf : IAddScriptElements );
commencer
AddIntf.AddIncludeFile('xmlshow.js');
fin;
fonction TCustomShowXMLButton.GetSubComponents : TObject ;
commencer
Résultat := nul;
fin;
function TCustomShowXMLButton.ImplContent(Options : TWebContentOptions;
ParentLayout : TLayout) : chaîne ;
var
Attributs : chaîne ;
Intf : ILayoutWebContent ;
NomVarFormulaire : chaîne ;
RowSetVarName : chaîne ;
commencer
AddQuotedAttrib(Attrs 'NOM' Nom);
AddQuotedAttrib(Style d'attributs 'STYLE');
AddQuotedAttrib(Attrs 'CLASS' StyleRule);
AddQuotedAttrib(Attrs 'VALUE' Self.Caption);
AddCustomAttrib(Attrs personnalisées);
si attribué (XMLData.XMLBroker) alors
commencer
FormVarName := XMLData.XMLBroker.SubmitFormVarName;
RowSetVarName := XMLData.XMLBroker.RowSetVarName(nil); // Ligne ligne définie nom de la variable
fin;
sinon (coNoScript dans Options.Flags) alors
Résultat :=
Format(''#13#10
[Attrs RowSetVarName XMLMethodName sXMLReadyVar])
autre
Résultat :=
Format(''#13#10
[Attres]);
si Assigned (ParentLayout) et ParentLayout.GetInterface (ILayoutWebContent Intf) alors
Résultat := Intf.LayoutButton(Result GetLayoutAttributes);
fin;
{ TShowXMLButton }
constructeur TShowXMLButton.Create(AOwner: TComponent);
commencer
hérité;
DefaultCaption := sShowXML ;
XMLMethodName := 'racine';
fin;
{ TShowDeltaButton }
constructeur TShowDeltaButton.Create(AOwner : TComponent);
commencer
hérité;
DefaultCaption := sShowDelta ;
XMLMethodName := 'getDelta()';
fin;
Le fichier msxml.dll est le suivant :
....
....
procédure TDHEDForm.OpenBtnClick(Expéditeur : TObject);
var
pVIn : OleVariant;
Invite : OleVariant ;
commencer
pVIn := '';
Invite := Vrai ;
DHTMLEdit1.LoadDocument (invite pVIn);
fin;
procédure TDHEDForm.SaveBtnClick(Expéditeur : TObject);
var
vo vb : OleVariant;
commencer
vo := DHTMLEdit1.CurrentDocumentPath;
si (vo <> '') alors
commencer
vb := faux;
fin
autre
commencer
vo := '';
vb := vrai;
fin;
DHTMLEdit1.SaveDocument(vo vb);
fin;
procédure TDHEDForm.SaveAsClick(Expéditeur : TObject);
var
vo vb : OleVariant;
commencer
vo := '';
vb := vrai;
DHTMLEdit1.SaveDocument(vo vb);
fin;
...
//本文为转贴,作者不详,仅供大家参考