start_tag Function

private pure function start_tag(self, is_indented) result(tag_)

Arguments

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

XML tag.

logical, intent(in), optional :: is_indented

Flag to check if tag is indented.

Return Value character(len=:), allocatable

The start tag string.

Description

Return <tag_name...> start tag.


Source Code

  pure function start_tag(self, is_indented) result(tag_)
  !---------------------------------------------------------------------------------------------------------------------------------
  !< Return `<tag_name...>` start tag.
  !---------------------------------------------------------------------------------------------------------------------------------
  class(xml_tag), intent(in)           :: self        !< XML tag.
  logical,        intent(in), optional :: is_indented !< Flag to check if tag is indented.
  character(len=:), allocatable        :: tag_        !< The start tag string.
  !---------------------------------------------------------------------------------------------------------------------------------

  !---------------------------------------------------------------------------------------------------------------------------------
  tag_ = tag_//'<'//self%tag_name
  if (self%attributes_number>0) tag_ = tag_//' '//self%attributes()
  tag_ = tag_//'>'
  if (present(is_indented)) then
    if (is_indented) tag_ = repeat(' ', self%indent)//tag_
  endif
  !---------------------------------------------------------------------------------------------------------------------------------
  endfunction start_tag