parse Subroutine

private 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.

Type Bound

xml_tag

Arguments

Type IntentOptional Attributes Name
class(xml_tag), intent(inout) :: self

XML tag.

character(len=*), intent(in) :: source

String containing the input.

integer(kind=I4P), intent(out), optional :: tstart

Starting index of tag inside the string.

integer(kind=I4P), intent(out), optional :: tend

Ending index of tag inside the string.


Calls

proc~~parse~~CallsGraph proc~parse xml_tag%parse is_allocated is_allocated proc~parse->is_allocated proc~get xml_tag%get proc~parse->proc~get 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 xml_tag%search proc~search->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 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