Add Delphi and the DOM
Welcome to the second part of a four-part series on Delphi and the DOM. In the first article, we discussed Delphi and XML. Now that you have some idea of the core elements of XML documents, we can talk about how to manipulate them in Delphi.

XML Documents and Delphi

There are two ways in which you can manipulate XML documents:

    *      Using the Document Object Model interface
    *      Using the Simple API for XML or SAX

The two techniques could not be more different from each other.

    *      The Document Object Model loads the entire document into a hierarchical tree of nodes, allowing you to read them and manipulate them to change the document. For this reason, the Document Object Model is suitable when you want to navigate the XML structure in memory and edit it, or for creating new documents from scratch.
    *      The Simple API for XML or SAX parses the document, firing an event for each element without building a structure in memory. Once parsed by the Simple API for XML, the document is lost, but this operation is generally much faster than the construction of the Document Object Model tree. Using the Simple API for XML is good for reading an XML document once, i.e if you are looking for a portion of its data.

There is another way to manipulate or to create XML documents: string management. Creating a document by adding strings is the fastest operation, particularly if you can do a single pass (and don't need to modify nodes already generated). Reading documents by strings is very fast, but can become difficult for complex structures.

Delphi provides two more methods you should know about. The first is the definition of interfaces that map the document structure; this method is used to access the document instead of the generic DOM interface. This approach makes for faster coding and more robust applications.The second approach is the development of transformations that enable you to read a generic XML document into a ClientDataSet component or save the dataset into an XML file for a given structure.

Which of these two is better? Well, that you will have to decide based on your needs. So how do we code for DOM in Delphi? That is what we will be looking at next.
Related Discussions
  • HOW TO KILL ANYOTHER PROGRAMS WITH DELPHI? (2001-01-02 08:04:42)
    Find the handle of the window using FindWindow or EnumWindows and use PostMessage(ProgramHandle, WM_CLOSE, 0, 0); I have not tried it, but it...
  • HOW TO GREP CHARACTERS IN DELPHI 3 (2001-01-02 16:29:32)
    Var Grep : String; Begin Grep := Copy('2000-46',6,2); End; The first parameter is a string or a dynamic array, the second is the index of...
  • HOW CAN I DEBUG DLL (2001-01-02 15:48:24)
    Do you mean how to find internal errors while writing a DLL file or how to get the exact error while calling a DLL Function ? /Filip
  • USING DLLS (2001-01-03 14:47:50)
    Hi again Goober ... :o) Let's take NETAPI32.DLL as an example. This DLL is created by Microsoft and the explanation of its use is described in...
  • DOT ON SCREEN (2001-01-02 18:42:55)
    Delphi does not support a Pixel function with a HDC, you have to use the Windows-API-function COLORREF SetPixel( HDC hdc, // handle...
  • HOW TO RUN DATABASE APPLICATION ON THE INTERNET (2001-01-02 18:04:54)
    This is possible using COM objects and ActiveX Server ... Don't ask how ... I'm not into COM object programming ... :o) Regards /Filip
  • HELP WITH CHDIR !!!! TURBO PASCAL VS DELPHI (2001-01-02 21:48:49)
    This is because the ChDir Procedure, the SetCurrentDir and SetCurrentDirectory Functions are changing the directory in the active process. Try...
  • FRIENDS IN DELPHI ?? (OR OTHER ACCESS WORKAROUNDS) (2001-01-04 00:08:37)
    One of the quirks of Delphi is that classes in the same unit can access protected and private methods and variables. Borland does this a lot in...
  • SENDING ICQ MSGS FROM DELPHI (2001-01-03 05:54:03)
    I tried the ICQ Api, but never used it. I've added a simple ICQPager component to delphipages (Winsock/TCPIP).. it might help... Q
  • RUNNING A DATABASE APPLICATION ON ANOTHER COMPUTER (2001-01-06 20:36:33)
    In the BDE on the other PC (the one without the database), you must add an alias to point to the location of the database in the format of:...
Latest News
Submit News Form Past News
Latest Forum Entries
Latest Searches