parse Subroutine

private subroutine parse(self, string, filename)

Parse xml data from string or file. XML data is linearized, a DOM structured is used.

Note

Self data are free before trying to parse new xml data: all previously parsed data are lost.

Type Bound

xml_file

Arguments

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

XML file.

character(len=*), intent(in), optional :: string

String containing xml data.

character(len=*), intent(in), optional :: filename

File name containing xml data.


Calls

proc~~parse~2~~CallsGraph proc~parse~2 xml_file%parse proc~load_file_as_stream load_file_as_stream proc~parse~2->proc~load_file_as_stream proc~parse_from_string xml_file%parse_from_string proc~parse~2->proc~parse_from_string proc~add_child xml_file%add_child proc~parse_from_string->proc~add_child proc~add_tag xml_file%add_tag proc~parse_from_string->proc~add_tag proc~get_tag_content get_tag_content proc~parse_from_string->proc~get_tag_content proc~parse_tag_name~2 parse_tag_name proc~parse_from_string->proc~parse_tag_name~2 proc~set xml_tag%set proc~parse_from_string->proc~set proc~add_child_id xml_tag%add_child_id proc~add_child->proc~add_child_id proc~find_matching_end_tag find_matching_end_tag proc~get_tag_content->proc~find_matching_end_tag proc~add_multiple_attributes xml_tag%add_multiple_attributes proc~set->proc~add_multiple_attributes proc~add_single_attribute xml_tag%add_single_attribute proc~set->proc~add_single_attribute proc~add_stream_attributes xml_tag%add_stream_attributes proc~set->proc~add_stream_attributes proc~add_multiple_attributes->proc~add_single_attribute proc~alloc_attributes xml_tag%alloc_attributes proc~add_single_attribute->proc~alloc_attributes proc~add_stream_attributes->proc~add_single_attribute fill fill proc~add_stream_attributes->fill partition partition proc~add_stream_attributes->partition slice slice proc~add_stream_attributes->slice

Called by

proc~~parse~2~~CalledByGraph proc~parse~2 xml_file%parse program~foxy_test_delete_tag foxy_test_delete_tag program~foxy_test_delete_tag->proc~parse~2 program~foxy_test_parse_file_simple foxy_test_parse_file_simple program~foxy_test_parse_file_simple->proc~parse~2 program~foxy_test_parse_string_nested_tags foxy_test_parse_string_nested_tags program~foxy_test_parse_string_nested_tags->proc~parse~2 program~foxy_test_parse_string_simple foxy_test_parse_string_simple program~foxy_test_parse_string_simple->proc~parse~2 program~foxy_test_write_tag foxy_test_write_tag program~foxy_test_write_tag->proc~parse~2

Source Code

   subroutine parse(self, string, filename)
   !< Parse xml data from string or file.
   !< XML data is linearized, a DOM structured is used.
   !<
   !< @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