Hi all,

I am totaly nes to this (XML), so I suppose i do something wrong.

I took the example from the Wiki XML Tutorial, and the simplified it.
(I use Lazarus svn revision 16824, with fpc 2.2.0 on Window ME)

Here's my code to write an XML file:

procedure TForm1.Button1Click(Sender: TObject);
var
  xdoc: TXMLDocument;                                  // variable to
document
  RootNode, parentNode, nofilho: TDOMNode;                    // variable to
nodes
  Fn: String;
begin
  Fn := 'F:\LazarusProjecten\XMLTest\test1.xml';
  //create a document
  xdoc := TXMLDocument.create;
  xdoc.Encoding := 'utf-8';

  //create a root node
  RootNode := xdoc.CreateElement('root');
  Xdoc.Appendchild(RootNode);                           // save root node

  //create a parent node
  RootNode:= xdoc.DocumentElement;
  parentNode := xdoc.CreateElement('child');
  RootNode.Appendchild(parentNode);                          // save parent
node

  //create a child node
  parentNode := xdoc.CreateElement('foo');                // create a child
node
  //nofilho := xdoc.CreateTextNode('Bart');         // insert a value to
node
  //parentNode.Appendchild(nofilho);                         // save node
  RootNode.ChildNodes.Item[0].AppendChild(parentNode);       // insert child
node in respective parent node

  //create a second child node
  parentNode := xdoc.CreateElement('bar');               // create a child
node
  //nofilho := xdoc.CreateTextNode('me, myself and I');               //
insert a value to node
  //parentNode.Appendchild(nofilho);                         // save node
  RootNode.ChildNodes.Item[0].AppendChild(parentNode);       // insert a
childnode in respective parent node

  writeXMLFile(xDoc,Fn);                     // write to XML
  Xdoc.free;                                          // free memory

  Memo1.Lines.LoadFromFile(Fn);
end;

This creates the following XML file:
<?xml version="1.0"?>
<root>
  <child>
    <foo/>
    <bar/>
  </child>
</root>

This file is more or less as I excpected it to be (i would think it would
include the encoding="utf-8").

The problem is, that for every child I create and append, I loose 4 blocks
of memory (60 bytes for these 4 blocks) (I used the heaptrace option with
compilation).
I commented out the CreateTetNode to try and see if it made any difference
in the (amount of) memory loss, but it seems to have no effect at all.

(I cannot include the total heaptrace report, since on win9x it's output
cannot be redirected, and the win9x console cannot be scrolled...)

What am I doing wrong here?

Bart
_______________________________________________
Lazarus mailing list
[email protected]
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to