parse Subroutine

private elemental subroutine parse(self, source, tstart, tend)

Type Bound

xml_tag

Arguments

Type IntentOptional Attributes Name
class(xml_tag), intent(inout) :: self
character(len=*), intent(in) :: source
integer(kind=I4P), intent(out), optional :: tstart
integer(kind=I4P), intent(out), optional :: tend

Calls

proc~~parse~~CallsGraph proc~parse xml_tag%parse proc~get xml_tag%get proc~parse->proc~get proc~is_allocated string%is_allocated proc~parse->proc~is_allocated proc~parse_attributes_names xml_tag%parse_attributes_names proc~parse->proc~parse_attributes_names proc~parse_tag_name xml_tag%parse_tag_name proc~parse->proc~parse_tag_name proc~get_attributes xml_tag%get_attributes proc~get->proc~get_attributes proc~get_value xml_tag%get_value proc~get->proc~get_value proc~alloc_attributes xml_tag%alloc_attributes proc~parse_attributes_names->proc~alloc_attributes

Called by

proc~~parse~~CalledByGraph proc~parse xml_tag%parse proc~search~2 xml_tag%search proc~search~2->proc~parse program~foxy_test_create_tag foxy_test_create_tag program~foxy_test_create_tag->proc~parse proc~get_content xml_tag%get_content proc~get_content->proc~search~2 proc~content xml_file%content proc~content->proc~get_content

Source Code

   elemental subroutine parse(self, source, tstart, tend)
   !< Parse the tag contained into a source string.
   !<
   !< It is assumed that the first tag contained into the source string is parsed, the others eventually present are omitted.
   !< Valid syntax are:
   !< + `<tag_name att1="att1 val" att2="att2 val"...>...</tag_name>`
   !< + `<tag_name att1="att1 val" att2="att2 val".../>`
   !< @note Inside the attributes value the symbols `<` and `>` are not allowed.
   class(xml_tag),         intent(inout) :: self      !< XML tag.
   character(*),           intent(in)    :: source    !< String containing the input.
   integer(I4P), optional, intent(out)   :: tstart    !< Starting index of tag inside the string.
   integer(I4P), optional, intent(out)   :: tend      !< Ending index of tag inside the string.
   integer(I4P)                          :: tstartd   !< Starting index of tag inside the string.
   integer(I4P)                          :: tendd     !< Ending index of tag inside the string.

   tstartd = 0
   tendd   = 0
   call self%parse_tag_name(source=source, tstart=tstartd, tend=tendd)
   if (self%tag_name%is_allocated()) then
      if (index(string=source(tstartd:tendd), substring='=')>0) call self%parse_attributes_names(source=source(tstartd:tendd))
      if (index(string=source, substring='</'//self%tag_name//'>')>0) &
         tendd = index(string=source, substring='</'//self%tag_name//'>') + len('</'//self%tag_name//'>') - 1
      call self%get(source=source(tstartd:tendd))
   endif
   if (present(tstart)) tstart = tstartd
   if (present(tend  )) tend   = tendd
   endsubroutine parse