OSDN Git Service

(none)
[gikonavigoeson/gikonavi.git] / GikoXMLDoc.pas
index ae3e00e..4279a7d 100644 (file)
@@ -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 \88È\8aO\82Ì\83m\81[\83h\82ª\95Â\82\82ç\82ê\82½\8fê\8d\87\82Ì\83m\81[\83h\96¼
 
-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