parse_file_simple Program

Uses

  • program~~parse_file_simple~~UsesGraph program~parse_file_simple parse_file_simple module~foxy foxy program~parse_file_simple->module~foxy module~penf~2 penf module~foxy->module~penf~2 module~foxy_xml_tag foxy_xml_tag module~foxy->module~foxy_xml_tag module~foxy_xml_file foxy_xml_file module~foxy->module~foxy_xml_file module~penf_b_size penf_b_size module~penf~2->module~penf_b_size module~penf_stringify~3 penf_stringify module~penf~2->module~penf_stringify~3 module~penf_global_parameters_variables~2 penf_global_parameters_variables module~penf~2->module~penf_global_parameters_variables~2 module~foxy_xml_tag->module~penf~2 module~stringifor~2 stringifor module~foxy_xml_tag->module~stringifor~2 module~foxy_xml_file->module~penf~2 module~foxy_xml_file->module~foxy_xml_tag module~penf_b_size->module~penf_global_parameters_variables~2 module~stringifor~2->module~penf~2 module~stringifor_string_t stringifor_string_t module~stringifor~2->module~stringifor_string_t module~penf_stringify~3->module~penf_b_size module~penf_stringify~3->module~penf_global_parameters_variables~2 iso_fortran_env iso_fortran_env module~penf_stringify~3->iso_fortran_env module~stringifor_string_t->module~penf~2 module~stringifor_string_t->iso_fortran_env module~face face module~stringifor_string_t->module~face module~befor64~4 befor64 module~stringifor_string_t->module~befor64~4 module~face->iso_fortran_env module~befor64~4->module~penf~2 module~befor64_pack_data_m~4 befor64_pack_data_m module~befor64~4->module~befor64_pack_data_m~4 module~befor64_pack_data_m~4->module~penf~2

Contents

Source Code


Variables

TypeAttributesNameInitial
character(len=:), allocatable:: source
character(len=:), allocatable:: parsed
type(xml_file) :: xfile
integer :: xunit
logical :: test_passed(1)

Source Code

program parse_file_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.
integer                       :: xunit          !< XML file unit.
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
open(newunit=xunit, file='parse_file_simple.xml', access='STREAM', form='UNFORMATTED')
write(unit=xunit)source
close(unit=xunit)

print "(A)", 'Parsing file'
call xfile%parse(filename='parse_file_simple.xml')
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)

open(newunit=xunit, file='parse_file_simple.xml')
close(unit=xunit, status='DELETE')

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