Convert the whole file data into a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(xml_file), | intent(in) | :: | self |
XML file. |
||
logical, | intent(in), | optional | :: | linearize |
Return a "linearized" string of tags without the XML hieararchy. |
Output string containing the whole xml file.
pure function stringify(self, linearize) result(string) !< Convert the whole file data into a string. class(xml_file), intent(in) :: self !< XML file. logical, intent(in), optional :: linearize !< Return a "linearized" string of tags without the XML hieararchy. logical :: linearize_ !< Linearize sentinel, local var. character(len=:), allocatable :: string !< Output string containing the whole xml file. character(len=:), allocatable :: tag_string !< Output string containing the current tag. integer(I4P) :: t !< Counter. logical, allocatable :: is_done(:) !< List of stringified tags. linearize_ = .false. ; if (present(linearize)) linearize_ = linearize string = '' if (linearize_) then if (self%nt>0) then do t=1, self%nt string = string//self%tag(t)%stringify(linearize=.true.)//new_line('a') enddo endif else if (self%nt>0) then allocate(is_done(self%nt)) ; is_done = .false. do t=1, self%nt if (is_done(t)) cycle if (self%tag(t)%children_number>0) then tag_string = '' call self%stringify_recursive(tag=self%tag(t), is_done=is_done, tag_string=tag_string) if (tag_string(1:1)==new_line('a')) tag_string = tag_string(2:) else tag_string = self%tag(t)%stringify(is_indented=.true.) endif string = string//tag_string//new_line('a') is_done(t) = .true. enddo endif endif if (string(len(string):len(string))==new_line('a')) string = string(:len(string)-1) endfunction stringify