parse Subroutine

private subroutine parse(self, string, filename)

Arguments

TypeIntentOptionalAttributesName
class(xml_file), intent(inout) :: self
character, intent(in), optional :: string
character, intent(in), optional :: filename

Calls

proc~~parse~~CallsGraph proc~parse parse proc~load_file_as_stream load_file_as_stream proc~parse->proc~load_file_as_stream

Contents

Source Code


Source Code

  subroutine parse(self, string, filename)
  !< Parse xml data from string or file.
  !<
  !< @note Self data are free before trying to parse new xml data: all previously parsed data are lost.
  class(xml_file),        intent(inout) :: self     !< XML file.
  character(*), optional, intent(in)    :: string   !< String containing xml data.
  character(*), optional, intent(in)    :: filename !< File name containing xml data.
  character(len=:), allocatable         :: source   !< String containing xml data.

  call self%free
  if (present(string)) then
    call self%parse_from_string(source_string=string)
  elseif (present(filename)) then
    source = load_file_as_stream(filename=filename, fast_read=.true.)
    call self%parse_from_string(source_string=source)
  endif
  endsubroutine parse