Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 2 - Delphi Wrapper Classes and XML
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Delphi Wrapper Classes and XML
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-11-17

    Table of Contents:
  • Delphi Wrapper Classes and XML
  • XML Properties, Methods, and Interface
  • A Demonstration
  • Second Part of Code

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Delphi Wrapper Classes and XML - XML Properties, Methods, and Interface


    (Page 2 of 4 )

    The XML document properties, methods and interface are then defined. The functions help us to manipulate the document elements.


    { IXMLDocument }


    TXMLDocOption = (doNodeAutoCreate, doNodeAutoIndent, doAttrNull,

    doAutoPrefix, doNamespaceDecl, doAutoSave);

    TXMLDocOptions = set of TXMLDocOption;


    TParseOption = (poResolveExternals, poValidateOnParse, poPreserveWhiteSpace,

    poAsyncLoad);

    TParseOptions = set of TParseOption;


    TXMLEncodingType = (xetUnknown, xetUCS_4BE, xetUCS_4LE, xetUCS_4Order2134,

    xetUCS_4Order3412, xetUTF_16BE, xetUTF_16LE, xetUTF_8, xetUCS_4Like,

    xetUTF_16BELike, xetUTF_16LELike, xetUTF_8Like, xetEBCDICLike);


    IXMLDocument = interface(IInterface)

    ['{395950C3-7E5D-11D4-83DA-00C04F60B2DD}']

    { Property Accessors }

    function GetActive: Boolean;

    function GetAsyncLoadState: Integer;

    function GetChildNodes: IXMLNodeList;

    function GetDocumentElement: IXMLNode;

    function GetDocumentNode: IXMLNode;

    function GetDOMDocument: IDOMDocument;

    function GetEncoding: DOMString;

    function GetFileName: DOMString;

    function GetModified: Boolean;

    function GetNodeIndentStr: DOMString;

    function GetOptions: TXMLDocOptions;

    function GetParseOptions: TParseOptions;

    function GetSchemaRef: DOMString;

    function GetStandAlone: DOMString;

    function GetVersion: DOMString;

    function GetXML: TStrings;

    procedure SetActive(const Value: Boolean);

    procedure SetDocumentElement(const Value: IXMLNode);

    procedure SetDOMDocument(const Value: IDOMDocument);

    procedure SetEncoding(const Value: DOMString);

    procedure SetFileName(const Value: DOMString);

    procedure SetNodeIndentStr(const Value: DOMString);

    procedure SetOptions(const Value: TXMLDocOptions);

    procedure SetParseOptions(const Value: TParseOptions);

    procedure SetStandAlone(const Value: DOMString);

    procedure SetVersion(const Value: DOMString);

    procedure SetXML(const Value: TStrings);


    The methods of the XML document object are defined here. You will recognize some of them in the application that we will build later on:

    { Methods }

    function AddChild(const TagName: DOMString): IXMLNode; overload;

    function AddChild(const TagName, NamespaceURI: DOMString): IXMLNode; overload;

    function CreateElement(const TagOrData, NamespaceURI: DOMString): IXMLNode;

    function CreateNode(const NameOrData: DOMString;

    NodeType: TNodeType = ntElement; const AddlData: DOMString = ''): IXMLNode;

    function GeneratePrefix(const Node: IXMLNode): DOMString;

    function GetDocBinding(const TagName: DOMString;

    DocNodeClass: TClass; NamespaceURI: DOMString = ''): IXMLNode;

    function IsEmptyDoc: Boolean;

    procedure LoadFromFile(const AFileName: DOMString);

    procedure LoadFromStream(const Stream: TStream; EncodingType:

    TXMLEncodingType = xetUnknown);

    procedure LoadFromXML(const XML: string); overload;

    procedure LoadFromXML(const XML: DOMString); overload;

    procedure Refresh;

    procedure RegisterDocBinding(const TagName: DOMString;

    DocNodeClass: TClass; NamespaceURI: DOMString = '');

    procedure Resync;

    procedure SaveToFile(const AFileName: DOMString);

    procedure SaveToStream(const Stream: TStream);

    procedure SaveToXML(var XML: DOMString); overload;

    procedure SaveToXML(var XML: string); overload;

    procedure SetOnAsyncLoad(const Value: TAsyncEventHandler);


    The properties of the document object are defined here. Again, you will notice some of them in the application that we will build shortly:


    { Properties }

    property Active: Boolean read GetActive write SetActive;

    property AsyncLoadState: Integer read GetAsyncLoadState;

    property ChildNodes: IXMLNodeList read GetChildNodes;

    property DocumentElement: IXMLNode read GetDocumentElement write SetDocumentElement;

    property DOMDocument: IDOMDocument read GetDOMDocument write SetDOMDocument;

    property Encoding: DOMString read GetEncoding write SetEncoding;

    property FileName: DOMString read GetFileName write SetFileName;

    property Modified: Boolean read GetModified;

    property Node: IXMLNode read GetDocumentNode;

    property NodeIndentStr: DOMString read GetNodeIndentStr write SetNodeIndentStr;

    property Options: TXMLDocOptions read GetOptions write SetOptions;

    property ParseOptions: TParseOptions read GetParseOptions write SetParseOptions;

    property SchemaRef: DOMString read GetSchemaRef;

    property StandAlone: DOMString read GetStandAlone write SetStandAlone;

    property Version: DOMString read GetVersion write SetVersion;

    property XML: TStrings read GetXML write SetXML;

    end;


    Some constants are then declared that will be used in the implementation of the unit:


    const

    NodeTypeNames: array[TNodeType] of string = { Do not localize }

    ('', 'Element','Attribute','Text','CDATASection', 'EntityRef','Entity',

    'ProcessingInstr', 'Comment','Document','DocumentType',

    'DocumentFragment','Notation');



    implementation


    end.

    More Delphi-Kylix Articles
    More By David Web


     

    DELPHI-KYLIX ARTICLES

    - Loading an XML Document into the DOM
    - Delphi Wrapper Classes and XML
    - Delphi and the DOM
    - Delphi and XML
    - Internet Access: Client Service
    - Finishing the Client for an Internet Access ...
    - The Client for an Internet Access Control Ap...
    - User Management for an Internet Access Contr...
    - Important Procedures for an Internet Access ...
    - Server Code for an Internet Access Control A...
    - Constructing the Interface for an Internet A...
    - Building a Server Application for an Interne...
    - Building an Internet Access Control Applicat...
    - Client Dataset: Working with Data Packets an...
    - Using the Client Dataset in an N-Tiered Appl...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT