[gtkada] Deleting Nodes with Glib.Xml

Borja Martín borjam at dagi3d.net
Sat Apr 19 18:24:19 CEST 2003


hi.
I would like to know if there is any way to delete nodes inside a xml document
Supose I have the following xml file:
<?xml version="1.0"?>
<users>
         <user>user1</user>
         <user>user2</user>
         <user>user3</user>
</users>

I would like for example to remove the node depending from their content. I 
have no problem searching for the nodes that have certain content, but have 
no idea how to delete them.
This is the pieces of code I have to search the nodes:

with gtk, glib.xml, Ada.Text_IO;
use gtk, Ada.text_Io;
procedure delete_node is
         type xmldata is null record;
         package gxml is new Glib.Xml(xmldata);
         use gxml;

         procedure deleteNode(name:String) is
                 found: Boolean := false;
                 document : Node_Ptr := Parse("test.xml");
                 userNode : Node_Ptr := document.child;
         begin
                 while (userNode /= null) and (not found) loop
                         if(userNode.value.all = name) then
                                 found := true;
                                 put_line("user found");
                                 -- here I should delete that node
                         end if;
                         userNode := userNode.next;
                 end loop;
         end deleteNode;
begin
         deleteNode("user2");
end delete_node;

Any idea how to achieve that?
Thx in advance.

/*********************
* Dagi3d  v3.0
* http://dagi3d.net
*********************/





More information about the gtkada mailing list