There are two ways to use XML documents in Delphi
Using XML Broker, it is built in Delphi. example:
Unit showxml;
Interface
Uses classes httpapp db dbclient Midas
XMLBROKR Webcomp Miditems;
Type
TCUSTOMSHOWXMLBUTTON = Class (TXMLButton IscriptComponent)
protected
Xmlmethodname: String;
{Iscriptcomponent}
Procedure addelements (Addintf: Iaddscriptelements);
Function GetSubcomponents: TOBJECT;
{IWebcontent Implementation}
Function Implcontent (Options: TWEBCONTENTOTIONS;
ParentLayout: TLAYOUT: String; Override;
END;
Tshowxmlbutton = Class (TCUSHOWXMLBUTTON)
public
Constructor Create (Aowner: Tcomponent); OVERRIDE;
Published
Property Custom;
Property style;
Property Stylelule;
Property Caption;
Property Xmlbroker;
Property XMLUSEParent;
END;
TshowDelTabutton = Class (tcustomshowxmlbutton)
public
Constructor Create (Aowner: Tcomponent); OVERRIDE;
Published
Property Custom;
Property style;
Property Stylelule;
Property Caption;
Property Xmlbroker;
Property XMLUSEParent;
END;
IMPLEMENTATION
Uses sysutils midprod;
ResourceString
Sshowxml = 'show xml';
Sshowdelta = 'Show Delta';
Procedure tcustomshowxmlbutton.addelements
Addintf: Iaddscriptelements;
Begin
Addintf.addincludefile ('Xmlshow.js');
END;
Function TCUSHOWXMLBUTTON.GETSUBComponents: TOBJECT
Begin
Result: = NIL;
END;
Function TCUSHOWXMLBUTTON.IMPLCONTENT (OPTIONS: TWEBCONTENTOTIONS;
ParentLayout: TLAYOUT: String;
VAR
Attrs: string;
INTF: ILAYOUTWEBCONTENT;
Formvarname: String;
RowsetVarname: String;
Begin
AddQuoteDattrib (Attrs 'Name' Name);
AddQuoteDattrib (Attrs 'Style' Style);
AddQuoteDattrib (Attrs 'Class' Stylelule);
AddQuoteDattrib (Attrs 'Value' Self.caption); AddCustomattrib (Attrs Custom);
IF assigned (xmldata.xmlbroker) THEN
Begin
Formvarname: = xmldata.xmlbroker.submitFormvarname;
RowSetvarname: = XmlData.xmlbroker.rowsetvarname (nil); // Row Row Set Var Name
END;
IF not (conncript in options.flags) THEN
Result: =
Format ('' # 13 # 10
[Attrs RowSetvarname XmlmethodName SXMLReadyvar])
Else
Result: =
Format ('' # 13 # 10
[Attrs]);
ILAYOoutWebcontent Intf (iLayoutWebcontent Intf) THENTLAYOTENTENT ILY
Result: = intf.LayoutButton (Result getLayOutaTRibutes);
END;
{Tshowxmlbutton}
Constructor TshowxmlButton.create (Aowner: Tcomponent);
Begin
inherited;
DEFAULTCAPTION: = SSHOWXML;
Xmlmethodname: = 'root';
END;
{Tshowdeltabutton}
Constructor TshowDelTabutton.create (Aowner: Tcomponent);
Begin
inherited;
DEFAULTCAPTION: = SSHOWDELTA;
XmlmethodName: = 'getDelta ()';
END;
Another method uses msxml.dll as follows:
....
....
Procedure TdhedForm.openbtnclick (Sender: TOBJECT);
VAR
PVIN: Olevariant;
Prompt: olevariant;
Begin
PVIN: = '';
Prompt: = true;
DHTMLDIT1.LOADICUMENT (PVIN Prompt);
END;
Procedure TdhedForm.savebtnclick (Sender: TOBJECT);
VAR
VO VB: Olevariant;
Begin
VO: = DHTMLEDIT1.CURRENTDocumentPath;
IF (Vo <> ') THEN
Begin
VB: = false;
end
Else
Begin
VO: = '';
VB: = true;
END;
DHTMledit1.savedocument (VO VB);
END;
Procedure TdhedForm.saveasclick (Sender: TOBJECT);
VAR
VO VB: Olevariant;
Begin
VO: = '';
VB: = true;
DHTMledit1.savedocument (VO VB);
END;
...
// This article is reposted, the author is unknown, only for your reference