This package provides a simple minded XML parser to be used with Gate.
Types |
---|
| |
| |
A node of the XML tree.
Each time a tag is found in the XML file, a new node is created, that
points to its parent, its children and its siblings (nodes at the same
level in the tree and with the same parent).
| |
| |
Pointer to a node of the XML tree.
| |
| |
The type of the extra data that can be attached to each node of the
XML tree. See for instance the package Glib.Glade.
|
Subprograms |
---|
function Parse (File : String) return Node_Ptr; |
Parse File and return the first node representing the XML file. |
function Parse_Buffer (Buffer : UTF8_String) return Node_Ptr; |
Parse a given Buffer in memory and return the first node representing the XML contents. |
procedure Print (N : Node_Ptr; File_Name : String := ""); |
Write the tree starting with N into a file File_Name. The generated file is valid XML, and can be parsed with the Parse function. If File_Name is the empty string, then the tree is printed on the standard output |
function Protect (S : String) return String; |
Return a copy of S modified so that it is a valid XML value |
function Find_Tag (N : Node_Ptr; Tag : UTF8_String) return Node_Ptr; |
Find a tag Tag in N and its brothers. |
function Get_Field (N : Node_Ptr; Field : UTF8_String) return String_Ptr; |
Return the value of the field 'Field' if present in the children of N. Return null otherwise. Do not free the returned value. |
procedure Add_Child (N : Node_Ptr; Child : Node_Ptr; Append : Boolean := False); |
Add a new child to a node. If Append is true, the child is added at the end of the current list of children. |
function Deep_Copy (N : Node_Ptr) return Node_Ptr; |
Return a deep copy of the tree starting with N. N can then be freed without affecting the copy. |
procedure Free (N : in out Node_Ptr; Free_Data : Free_Specific_Data := null); |
Free the memory allocated for a node and its children. It also disconnects N from its parent. If Free_Data is not null, it is used to free the memory occupied by the Specific_Data for each node. |
function Get_Attribute (N : in Node_Ptr; Attribute_Name : in UTF8_String; Default : in UTF8_String := "") return UTF8_String; |
Return the value of the attribute 'Attribute_Name' if present. Special XML characters have already been interpreted in the result string. Return Default otherwise. |
procedure Set_Attribute (N : Node_Ptr; Attribute_Name, Attribute_Value : UTF8_String); |
Create a new attribute, or replace an existing one. The attribute value is automatically protected for special XML characters |
function Find_Tag_With_Attribute (N : Node_Ptr; Tag : UTF8_String; Key : UTF8_String; Value : UTF8_String := "") return Node_Ptr; |
Find a tag Tag in N that has a given key (and value if given). |