foxy_test_parse_string_simple Program

Uses

  • program~~foxy_test_parse_string_simple~~UsesGraph program~foxy_test_parse_string_simple foxy_test_parse_string_simple module~foxy foxy program~foxy_test_parse_string_simple->module~foxy module~foxy_xml_file foxy_xml_file module~foxy->module~foxy_xml_file module~foxy_xml_tag foxy_xml_tag module~foxy->module~foxy_xml_tag penf penf module~foxy->penf module~foxy_xml_file->module~foxy_xml_tag module~foxy_xml_file->penf module~foxy_xml_tag->penf stringifor stringifor module~foxy_xml_tag->stringifor

FoXy test.


Calls

program~~foxy_test_parse_string_simple~~CallsGraph program~foxy_test_parse_string_simple foxy_test_parse_string_simple proc~parse~2 xml_file%parse program~foxy_test_parse_string_simple->proc~parse~2 proc~stringify~2 xml_file%stringify program~foxy_test_parse_string_simple->proc~stringify~2 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~stringify xml_tag%stringify proc~stringify~2->proc~stringify proc~stringify_recursive xml_file%stringify_recursive proc~stringify~2->proc~stringify_recursive 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 chars chars proc~stringify->chars is_allocated is_allocated proc~stringify->is_allocated proc~end_tag xml_tag%end_tag proc~stringify->proc~end_tag proc~self_closing_tag xml_tag%self_closing_tag proc~stringify->proc~self_closing_tag proc~start_tag xml_tag%start_tag proc~stringify->proc~start_tag proc~stringify_recursive->proc~stringify proc~stringify_recursive->proc~stringify_recursive 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

Variables

Type Attributes Name Initial
character(len=:), allocatable :: source

String containing the source XML data.

character(len=:), allocatable :: parsed

String containing the parsed XML data.

type(xml_file) :: xfile

XML file handler.

logical :: test_passed(1)

List of passed tests.


Source Code

program foxy_test_parse_string_simple
!< FoXy test.
use foxy, only: xml_file

implicit none
character(len=:), allocatable :: source         !< String containing the source XML data.
character(len=:), allocatable :: parsed         !< String containing the parsed XML data.
type(xml_file)                :: xfile          !< XML file handler.
logical                       :: test_passed(1) !< List of passed tests.

test_passed = .false.

print "(A)", 'Input XML data:'
source = '<first x="1" y="c" z="2">lorem ipsum...</first>'//new_line('a')//&
         '<second a1="2"/>'//new_line('a')//&
         '<third>bye</third>'//new_line('a')//&
         '<fourth a="3">bye bye Mrs. Robinson</fourth>'//new_line('a')//&
         '<fift>'//new_line('a')//&
         '  <nested level="1">I am supported! Nested tag at level 1</nested>'//new_line('a')//&
         '  <nested2 level="1">'//new_line('a')//&
         '    <nested3 level="2">Nested tag at level 2</nested3>'//new_line('a')//&
         '  </nested2>'//new_line('a')//&
         '</fift>'
print "(A)", source

print "(A)", 'Parsing file'
call xfile%parse(string=source)
print "(A)", 'Parsed data'
parsed = xfile%stringify()
print "(A)", parsed
test_passed(1) = trim(source)==trim(parsed)
print "(A,L1)", 'Is parsed data correct? ', test_passed(1)

print "(A,L1)", new_line('a')//'Are all tests passed? ', all(test_passed)
endprogram foxy_test_parse_string_simple