get_content Subroutine

private pure subroutine get_content(self, name, content)

Arguments

TypeIntentOptionalAttributesName
class(xml_tag), intent(in) :: self
character, intent(in) :: name
character(len=:), intent(out), allocatable:: content

Contents

Source Code


Source Code

  pure subroutine get_content(self, name, content)
  !< Return tag content of self (or its nested tags) if named *name*.
  !<
  !< @note If there is no value, the *content* string is returned deallocated.
  class(xml_tag),                intent(in)  :: self    !< XML tag.
  character(*),                  intent(in)  :: name    !< Searched tag name.
  character(len=:), allocatable, intent(out) :: content !< Tag content.
  type(xml_tag)                              :: tag     !< Dummy XML tag.

  if (allocated(content)) deallocate(content)
  if (self%tag_name%is_allocated()) then
    if (self%tag_name==name) then
      if (self%tag_content%is_allocated()) content = self%tag_content%chars()
    else
      if (self%tag_content%is_allocated()) then
        call tag%search(tag_name=name, source=self%tag_content%chars())
        if (tag%tag_content%is_allocated()) content = tag%tag_content%chars()
      endif
    endif
  endif
  endsubroutine get_content