Download MSXML 4 from Microsoft (or get it from MSDN).  Version 4 has more
features and a few bugs fixed.  Install it and use Delphi to create a PAS
unit from the type library (msxml2_tlb).

// Include the PAS unit into your unit.
uses SysUtils, Classes, msxml2_tlb, Variants, ActiveX;

var
  dom: IXMLDomDocument2;
  root, node: ICMLDomNode;
  stm: TStream;
  istm: IStream;

begin
  dom := CoDOMDocument40.Create;
  // or if you need to access it from multiple threads then
  // dom := CoFreeThreadedDOMDocument40.Create;

  // Create the root node
  root := dom.CreateElement ('SomeTag');
  dom.documentElement := root;

  // Create other elements on the root...
  node := dom.CreateElement ('Node1');
  node.nodeValue := 'Some text'
  root.appendChild (node);

  node := dom.CreateElement ('Node2');
  node.nodeValue := 'Some other text'
  root.appendChild (node);

  // Show the XML
  ShowMessage (root.xml);

  // Save the XML
  stm := TFileStream.Create ('test.xml', fmCreate);
  istm := TStreamAdapter.Create (stm, soOwned);
  dom.save (istm);
  istm := Nil; // Close the file

----- Original Message -----
> Has anyone had any experience using this to create an XML document from
> scratch ?
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to