views:

457

answers:

3

I'm in doubt if I should use TXMLTransformProvider or TXMLDocument.

TXMLTransformProvider looks more maintainable, and it seems to me that using it will require less coding than TXMLDocument.

In the other hand TXMLDocument looks more flexible.

What I need is to generate and parse a XML document with nested attributes, map it to master-detail clientDataSets and write back one XML document.

Do you have tips on this?

Thanks.

+3  A: 

This is just anecdotal, I have no idea what a best practice would be:

I was using that TXMLDocument for a little while, but it's pretty cumbersome and at least the Delphi 7 version didn't let me do XPath, which is pretty much why I'd want to use XML in the first place.

I imported the type library for IXMLDomDocument2 and I've been using that ever since. I really don't understand how it all works, but it's pretty awesome, and all the help is in the MSDN.

Peter Turner
+6  A: 

If the data files are from an outside source, my first thought would be the XML Binding Wizard. Here's a short video tutorial, too.

If you are generating the XML from your own data source, you could link it to a TClientDataSet and save it as XML. This is convenient because you can re-load the XML and just treat it like any other dataset.

If the data is extremely large, it will take a long time to read in to a DOM in memory. I would look at a SAX processor. This is a different process, and doesn't let you navigate a tree in memory the same way, but it's much faster.

If you're OK to manipulate the XML yourself and you aren't dealing with very large XML files, I like Peter's idea of importing the MSXML library and using it directly. This performs better than using TXMLDocument.

Bruce McGee
Alister
Hi Alister. Yes, I should have included a direct link.
Bruce McGee
A: 

Solutions from Bruce and Peter are ok, but they require, that the client machine has MSXML installed.

I would recommend DIXML, especially if you will need validation and/or transformation of these XML files.

ErvinS