Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(xml_file), | intent(inout) | :: | self | XML file. |
||
character(len=*), | intent(in) | :: | source_string | String containing xml data. |
Parse xml data from string.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(xml_tag), | public | :: | tag | Dummy xml tag. |
|||
integer(kind=I4P), | public | :: | tstart | Counter for tracking string parsing. |
|||
integer(kind=I4P), | public | :: | tend | Counter for tracking string parsing. |
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