X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=GikoXMLDoc.pas;h=4279a7db1e371b80608acfd5313dc928f9fc866a;hb=1b2959cad53beb8917583092d06901b855770190;hp=ae3e00e834ca84231ae502da677142c9d40eef40;hpb=36f74903cfa5b87fb676cb6503382f637da6926c;p=gikonavigoeson%2Fgikonavi.git diff --git a/GikoXMLDoc.pas b/GikoXMLDoc.pas index ae3e00e..4279a7d 100644 --- a/GikoXMLDoc.pas +++ b/GikoXMLDoc.pas @@ -34,7 +34,8 @@ type function GetAttribute( const Name : string ) : string; function GetNode( Index : Integer ) : IXMLNode; public - constructor Create; + constructor Create; + destructor Destroy; override; property NodeName : string read FNodeName write FNodeName; property Attributes[ const Name : string ] : string read GetAttribute; @@ -65,9 +66,10 @@ function XMLReadNode( var node : IXMLNode ) : string; // node ˆÈŠO‚̃m[ƒh‚ª•Â‚¶‚ç‚ꂽê‡‚̃m[ƒh–¼ -function LoadXMLDocument( - const fileName : string -) : IXMLDocument; +procedure LoadXMLDocument( + const fileName : string; + var doc : IXMLDocument +); //================================================== const @@ -83,13 +85,29 @@ implementation //================================================== // Constructor -constructor IXMLNode.Create(); +constructor IXMLNode.Create; begin + inherited; + FCount := 0; end; +// Destructor +destructor IXMLNode.Destroy; +var + i : Integer; +begin + + for i := FCount - 1 downto 0 do + FNodes[ i ].Free; + FChildNodes.Free; + + inherited; + +end; + function IXMLNode.GetAttribute( const Name : string ) : string; var i : Integer; @@ -424,25 +442,29 @@ begin end; end; -function LoadXMLDocument( - const fileName : string -) : IXMLDocument; +procedure LoadXMLDocument( + const fileName : string; + var doc : IXMLDocument +); type xmlMode = ( xmlHoge ); var xmlFile : TFileStream; - doc : IXMLDocument; begin - - doc := IXMLDocument.Create; + //Result := IXMLDocument.Create; + //doc := IXMLDocument.Create; xmlFile := TFileStream.Create( fileName, fmOpenRead ); - XMLReadNode( xmlFile, IXMLNode( doc ) ); - xmlFile.Free; - Result := doc; + try + XMLReadNode( xmlFile, IXMLNode( doc ) ); + //XMLReadNode( xmlFile, IXMLNode( Result ) ); + finally + xmlFile.Free; + end; + + //Result := doc; end; end. - \ No newline at end of file