* Gnatcom problem with MS XML
@ 2005-03-18 10:58 bubble
2005-03-19 10:29 ` Stephen Leake
2005-03-25 17:36 ` David Botton
0 siblings, 2 replies; 3+ messages in thread
From: bubble @ 2005-03-18 10:58 UTC (permalink / raw)
dear all:
I am learning how to use Gnatcom .
I do a COM's practice ; the practice is Microsoft XML COM Library(msxml3.dll
and msxml5.dll) .
I get some problem in practice and I can not sure where problem is?
I write my questions in code comment.
if you can understand my problem , could you explain why?
thank you.
my OS is windows XP.
my compiler is GNAT 3.15P + Gnatcom
--------------------------------------------------------------------------------------------
-------this is full complete test code.
----------------------------------------------------------------------------------------------
with Gnatcom;
with Gnatcom.Initialize;
with Gnatcom.Bstr;
with Gnatcom.Variant;
with Gnatcom.Types;
with Ada.Text_Io;
with Msxml5.Ixmldomdocument_Interface;
with Msxml5.Ixmldomelement_Interface;
with Msxml5.Ixmldomnode_Interface;
procedure Test is
use Msxml5;
use Gnatcom;
Dom : Ixmldomdocument_Interface.Ixmldomdocument_Type;
P_Root : Pointer_To_Ixmldomelement;
Node : Ixmldomelement_Interface.Ixmldomelement_Type;
Node2 : Ixmldomelement_Interface.Ixmldomelement_Type;
begin
Gnatcom.Initialize.Initialize_Com;
--- initialize COM environment
Ixmldomdocument_Interface.Create(Dom,Clsid_Domdocument);
P_Root
:=Ixmldomdocument_Interface.Createelement(Dom,Gnatcom.Bstr.To_Bstr("root"));
Ixmldomdocument_Interface.Putref_Documentelement(Dom,P_Root );
Ixmldomelement_Interface.Attach (Node,P_Root );
Ixmldomelement_Interface.Attach (Node2,P_Root ); ---here I get problem
-----------------------
------------------------- why can not attach P_Root to Node twice?
-------------------------
-------------------------- if I write the statement "
Ixmldomelement_Interface.Attach (Node,P_Root ); " twice.
-------------------------- such as
--------------------------
------------------------- Ixmldomelement_Interface.Attach (Node,P_Root );
<- pass
-------------------------- Ixmldomelement_Interface.Attach (Node,P_Root );
<- crash here
--------------------------
-------------------------- it will crash at second statement.
--------------------------
-------------------------- if my code is
--------------------------
------------------------- Ixmldomelement_Interface.Attach (Node,P_Root );
<- pass
------------------------- Ixmldomelement_Interface.Attach (Node2,P_Root );
<- pass
--------------------------
-------------------------- perfect work and I still don't know why?
--------------------------
for I in 1 .. 2 loop
declare
Tag : Types.Bstr := Bstr.To_Bstr
("child");
Ns : Types.Bstr := Bstr.To_Bstr
("");
Node_Type : Types.Variant :=
Variant.To_Variant (Node_Element);
P_Child : Pointer_To_Ixmldomnode;
Child : Ixmldomnode_Interface.Ixmldomnode_Type;
begin
P_Child:=Ixmldomdocument_Interface.Createnode (Dom, Node_Type, Tag,
Ns);
declare
X_Child : Pointer_To_Ixmldomnode :=
Ixmldomelement_Interface.Appendchild (Node, P_Child);
begin
---------
---------
--------- here I do attach x_child to child over twice again
--------- the code is
---------
---------- Ixmldomnode_Interface.Attach (Child,X_Child ); <-
pass
---------- Ixmldomnode_Interface.Attach (Child,X_Child );
<-pass
---------
---------
Ixmldomnode_Interface.Attach (Child,X_Child );
Ixmldomnode_Interface.Attach (Child,X_Child );
end;
Bstr.Free(Tag);
Bstr.Free(Ns);
end;
end loop;
declare
Xml : Gnatcom.Types.Bstr;
begin
Xml:=Ixmldomdocument_Interface.Get_Xml(Dom);
Ada.Text_Io.Put_Line(Gnatcom.Bstr.To_Ada(Xml));
Gnatcom.Bstr.Free(Xml);
end;
end;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-03-25 17:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-18 10:58 Gnatcom problem with MS XML bubble
2005-03-19 10:29 ` Stephen Leake
2005-03-25 17:36 ` David Botton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox