On Mon, 21 Mar 2011 15:34:28 +0100
Reimar Grabowski <reimg...@web.de> wrote:

>[...]
> I am to lazy to attach the code, so here it is (you should know how to get it 
> into Lazarus without too much hassle :) ):
> 
> program xmlattributes;
> 
> {$mode objfpc}{$H+}
> 
> uses
>   {$IFDEF UNIX}{$IFDEF UseCThreads}
>   cthreads,
>   {$ENDIF}{$ENDIF}
>   Classes, SysUtils, CustApp,
>   DOM, XMLWrite;
> type
> 
>   { TXMLAttributes }
> 
>   TXMLAttributes = class(TCustomApplication)
>   protected
>     procedure DoRun; override;
>   public
>   end;
> 
> { TXMLAttributes }
> 
> procedure TXMLAttributes.DoRun;
> var
>   ErrorMsg: String;
>   Document: TXMLDocument;
>   RootNode, Node: TDOMNode;
> begin
>   try
>     Document:=TXMLDocument.Create;
>     RootNode:=Document.CreateElement('ROOT');
>     TDOMElement(RootNode).SetAttribute('someAttrib', 'someValue');
>     Document.AppendChild(RootNode);
> 
>     RootNode:=Document.DocumentElement;
>     Node:=Document.CreateElement('SomeNode');
>     TDOMElement(Node).SetAttribute('aaaAttribute', '1');
>     TDOMElement(Node).SetAttribute('aAttribute', '2');
>     TDOMElement(Node).SetAttribute('ccAttribute', '4');
>     TDOMElement(Node).SetAttribute('bAttribute', '3');
>     RootNode.Appendchild(Node);
> 
>     WriteXMLFile(Document, 'test.xml');
>   finally
>     Document.Free;
>   end;
> 
>   // stop program loop
>   Terminate;
> end;
> 
> var
>   Application: TXMLAttributes;
> 
> {$R *.res}
> 
> begin
>   Application:=TXMLAttributes.Create(nil);
>   Application.Title:='XMLAttributes';
>   Application.Run;
>   Application.Free;
> end.

Thanks.

 
> someone@somewhere:~/pascal/Projects/xmldemo$ cat test.xml 
> <?xml version="1.0"?>
> <ROOT someAttrib="someValue">
>   <SomeNode aAttribute="2" bAttribute="3" ccAttribute="4" aaaAttribute="1"/>
> </ROOT>
> 
> Looks like the order is governed by the length of the attribute name first 
> and then alphabetically.

Yes, that is what CompareDOMStrings does.
Probably for speed reasons.
This function is fixed in the code.

Mattias
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to