get_value Subroutine

private elemental subroutine get_value(self, source)

Arguments

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

XML tag.

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

String containing data.

Description

Get the tag value from source after tag_name has been set.


Variables

TypeVisibility AttributesNameInitial
integer, public :: c1

Counter.

integer, public :: c2

Counter.


Source Code

  elemental subroutine get_value(self, source)
  !---------------------------------------------------------------------------------------------------------------------------------
  !< Get the tag value from source after tag_name has been set.
  !---------------------------------------------------------------------------------------------------------------------------------
  class(xml_tag), intent(inout) :: self   !< XML tag.
  character(*),   intent(in)    :: source !< String containing data.
  integer                       :: c1     !< Counter.
  integer                       :: c2     !< Counter.
  !---------------------------------------------------------------------------------------------------------------------------------

  !---------------------------------------------------------------------------------------------------------------------------------
  call self%tag_content%free
  self%is_self_closing = .false.
  if (index(string=source, substring='<'//self%tag_name)>0) then
    c2 = index(string=source, substring='</'//self%tag_name//'>')
    if (c2>0) then ! parsing tag value
      c1 = index(string=source, substring='>')
      if (c1+1<c2-1) self%tag_content = source(c1+1:c2-1)
    else
      self%is_self_closing = .true.
    endif
  endif
  !---------------------------------------------------------------------------------------------------------------------------------
  endsubroutine get_value