comp.lang.ada
 help / color / mirror / Atom feed
From: Al Christians <achrist@easystreet.com>
Subject: Re: XML for Win32
Date: Mon, 15 Oct 2001 13:14:49 -0700
Date: 2001-10-15T13:14:49-07:00	[thread overview]
Message-ID: <3BCB43B9.1D861B23@easystreet.com> (raw)
In-Reply-To: 3BCB3F12.3CDBC35E@easystreet.com

At first glance, the following appears to work as a variant
of the Win32-XML code from AdaPower.  What should I straighten 
out?


Al



----------------------Code Follows-----------------------

with GNAT.IO; use GNAT.IO;

with Interfaces.C;

with GnatCom.Types;
with GnatCom.BSTR; use GnatCom.BSTR;
with GnatCom.Variant; use GnatCom.Variant;
with GnatCom.Initialize;

with MSXML;

with MSXML.IXMLDomDocument_Interface; 
use  MSXML.IXMLDomDocument_Interface; 

with MSXML.IXMLDomNode_Interface;
with MSXML.IXMLDomNodeList_Interface;
use MSXML;

procedure XMLWalk is

   use type GnatCom.Types.VARIANT_BOOL;

   -- Document   : Dispinterface_Type;
   Document   : MSXML.IXMLDomDocument_Interface.IXMLDomDocument_Type;
   Node       : IXMLDOMNode_Interface.IXMLDOMNode_Type;

   Input_File : aliased GnatCom.Types.Variant 
                        := To_Variant("J:\QAReview\Src\test.xml");

   Result     : GnatCom.Types.Variant_Bool;

   procedure Walk (Node  : IXMLDOMNode_Interface.IXMLDOMNode_Type;
                   Level : Integer := 0)
   is
      use type Interfaces.C.Long;

      Node_List : IXMLDOMNodeList_Interface.IXMLDOMNodeList_Type;
      M         : Interfaces.C.Long;      
      Name      : GnatCom.Types.BSTR;
      Value     : GnatCom.Types.Variant;
   begin
      begin
         Name := IXMLDOMNode_Interface.Get_NodeName(Node);
         Value := IXMLDOMNode_Interface.Get_NodeValue(Node);
      exception
         when others =>
            Initialize(Value);
      end;

      for N in 1 .. Level loop
         Put(" ");
      end loop;

      Put_Line("Name: " & To_Ada(Name) & 
               "  Value: " & To_Ada(Value) &
               "  Level: " & Integer'Image(Level));

      IXMLDOMNodeList_Interface.Attach
        (Node_List,
         IXMLDOMNode_Interface.Get_ChildNodes(Node));
         
      M := IXMLDOMNodeList_Interface.Get_Length(Node_List);   
      Put_Line("Nodes:"  & Natural'Image(Natural(M)));

      for N in 1 .. M loop
         declare
            Next_Node : IXMLDOMNode_Interface.IXMLDOMNode_Type;
         begin
            IXMLDOMNode_Interface.Attach
              (Next_Node,
               IXMLDOMNodeList_Interface.NextNode(Node_List));
            Walk(Next_Node, Level+1);
         end;
      end loop;
      
      GnatCom.BSTR.Free(Name);
      GnatCom.Variant.Free(Value);

   end Walk;

begin
   GnatCom.Initialize.Initialize_Com;
   Put_Line("Creating Document...");
   Create( Document, CLSID_DOMDocument);

   IXMLDOMDocument_Interface.Put_Async(Document, 0);

   Put_Line("Loading Document...");
   Result := IXMLDomDocument_Interface.Load(Document, Input_File);

   if Result /= 0 then
      Put_Line("Document Loaded...");
      MSXML.IXMLDomNode_Interface.Attach( Node, cloneNode(Document,
-1));
      Walk(Node);
   end if;

   Free(Input_File);

end XMLWalk;



  reply	other threads:[~2001-10-15 20:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-15 17:31 XML for Win32 Al Christians
2001-10-15 18:19 ` Pascal Obry
2001-10-15 19:54   ` Al Christians
2001-10-15 20:14     ` Al Christians [this message]
2001-10-16 23:10       ` David Botton
2001-10-17  1:34         ` Al Christians
2001-10-17  1:53           ` David Botton
2001-10-17  3:00             ` Al Christians
2001-10-17 14:12               ` David Botton
2001-10-17 16:16                 ` Al Christians
2001-10-30 10:03 ` Emmanuel Briot
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox