xml_file Derived Type

type, public :: xml_file

type~~xml_file~~InheritsGraph type~xml_file xml_file type~xml_tag xml_tag type~xml_tag->type~xml_file tag type~string string type~string->type~xml_tag tag_name, tag_content, attribute
Help


XML file class.


Components

TypeVisibility AttributesNameInitial
integer(kind=I4P), private :: Nt =0

Number of XML tags.

type(xml_tag), private, allocatable:: tag(:)

XML tags array.


Finalization Procedures

final :: finalize

Free dynamic memory when finalizing.

  • private subroutine finalize(file)

    Arguments

    Type IntentOptional AttributesName
    type(xml_file), intent(inout) :: file

    XML file.

    Description

    Free dynamic memory when finalizing.


Type-Bound Procedures

procedure, public :: free

Free dynamic memory.

  • private elemental subroutine free(self)

    Arguments

    Type IntentOptional AttributesName
    class(xml_file), intent(inout) :: self

    XML file.

    Description

    Free dynamic memory.

procedure, public :: parse

Parse xml data from string or file.

  • private subroutine parse(self, string, filename)

    Arguments

    Type IntentOptional AttributesName
    class(xml_file), intent(inout) :: self

    XML file.

    character(len=*), intent(in), optional :: string

    String containing xml data.

    character(len=*), intent(in), optional :: filename

    File name containing xml data.

    Description

    Parse xml data from string or file.

procedure, public :: content

Return tag content of tag named name.

  • private pure function content(self, name)

    Arguments

    Type IntentOptional AttributesName
    class(xml_file), intent(in) :: self

    XML file.

    character(len=*), intent(in) :: name

    Tag name.

    Return Value character(len=:), allocatable

    Tag content.

    Description

    Return tag content of tag named name.

procedure, public :: stringify

Convert the whole file data into a string.

  • private pure function stringify(self) result(string)

    Arguments

    Type IntentOptional AttributesName
    class(xml_file), intent(in) :: self

    XML file.

    Return Value character(len=:), allocatable

    Output string containing the whole xml file.

    Description

    Convert the whole file data into a string.

procedure, public :: add_tag

Add tag to XML file.

  • private elemental subroutine add_tag(self, tag)

    Arguments

    Type IntentOptional AttributesName
    class(xml_file), intent(inout) :: self

    XML file.

    type(xml_tag), intent(in) :: tag

    XML tag.

    Description

    Add tag to XML file.

procedure, public :: delete_tag

Add tag from XML file.

  • private elemental subroutine delete_tag(self, name)

    Arguments

    Type IntentOptional AttributesName
    class(xml_file), intent(inout) :: self

    XML file.

    character(len=*), intent(in) :: name

    XML tag name.

    Description

    Delete tag from XML file.

procedure, private :: parse_from_string

Parse xml data from string.

  • private subroutine parse_from_string(self, source_string)

    Arguments

    Type IntentOptional AttributesName
    class(xml_file), intent(inout) :: self

    XML file.

    character(len=*), intent(in) :: source_string

    String containing xml data.

    Description

    Parse xml data from string.

Source Code

type, public:: xml_file
  !< XML file class.
  !<
  !< @todo The "delete" facility is incomplete: nested tags are not taken into account. Better support will with the
  !< "dom" facility.
  private
  integer(I4P)               :: Nt = 0 !< Number of XML tags.
  type(xml_tag), allocatable :: tag(:) !< XML tags array.
  contains
    ! public methods
    procedure :: free       !< Free dynamic memory.
    final     :: finalize   !< Free dynamic memory when finalizing.
    procedure :: parse      !< Parse xml data from string or file.
    procedure :: content    !< Return tag content of tag named *name*.
    procedure :: stringify  !< Convert the whole file data into a string.
    procedure :: add_tag    !< Add tag to XML file.
    procedure :: delete_tag !< Add tag from XML file.
    ! private methods
    procedure, private :: parse_from_string !< Parse xml data from string.
endtype xml_file