parse_from_string Subroutine

private subroutine parse_from_string(self, source_string)

Arguments

TypeIntentOptionalAttributesName
class(xml_file), intent(inout) :: self
character, intent(in) :: source_string

Contents

Source Code


Source Code

  subroutine parse_from_string(self, source_string)
  !< Parse xml data from string.
  class(xml_file), intent(inout) :: self          !< XML file.
  character(*),    intent(in)    :: source_string !< String containing xml data.
  type(xml_tag)                  :: tag           !< Dummy xml tag.
  integer(I4P)                   :: tstart        !< Counter for tracking string parsing.
  integer(I4P)                   :: tend          !< Counter for tracking string parsing.

  tstart = 1
  tend = 0
  do while(tstart<len(source_string))
    call tag%free
    call tag%parse(source=source_string(tstart:), tend=tend)
    if (tend==0) exit
    if (tag%is_parsed()) call self%add_tag(tag)
    tstart = tstart + tend
  enddo
  endsubroutine parse_from_string