get_value Subroutine

private elemental subroutine get_value(self, source)

Type Bound

xml_tag

Arguments

Type IntentOptional Attributes Name
class(xml_tag), intent(inout) :: self
character(len=*), intent(in) :: source

Called by

proc~~get_value~~CalledByGraph proc~get_value xml_tag%get_value proc~get xml_tag%get proc~get->proc~get_value proc~parse xml_tag%parse proc~parse->proc~get proc~parse_from_string xml_file%parse_from_string proc~parse_from_string->proc~parse proc~search xml_tag%search proc~search->proc~parse program~create_tag create_tag program~create_tag->proc~parse proc~get_content xml_tag%get_content proc~get_content->proc~search proc~parse~2 xml_file%parse proc~parse~2->proc~parse_from_string proc~content xml_file%content proc~content->proc~get_content program~delete_tag delete_tag program~delete_tag->proc~parse~2 program~parse_file_simple parse_file_simple program~parse_file_simple->proc~parse~2 program~parse_string_simple parse_string_simple program~parse_string_simple->proc~parse~2 program~write_tag write_tag program~write_tag->proc~parse~2

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