source: XMLF90/doc/Tutorial/sax/simple.f90 @ 6

Last change on this file since 6 was 6, checked in by ymipsl, 15 years ago

Import des sources XMLF90

File size: 887 bytes
Line 
1module m_aux
2use flib_sax
3private
4public :: begin_element_print
5
6contains !---------------- handler subroutine follows
7
8subroutine begin_element_print(name,attributes)
9   character(len=*), intent(in)     :: name
10   type(dictionary_t), intent(in)   :: attributes
11   
12   character(len=3)  :: id
13   integer           :: status
14   
15   print *, "Start of element: ", name
16   if (has_key(attributes,"id")) then
17      call get_value(attributes,"id",id,status)
18      print *, "  Id attribute: ", id
19   endif
20end subroutine begin_element_print
21
22end module m_aux
23
24program simple
25use flib_sax
26use m_aux
27
28type(xml_t)        :: fxml      ! XML file object (opaque)
29integer            :: iostat    ! Return code (0 if OK)
30
31call open_xmlfile("inventory.xml",fxml,iostat)
32if (iostat /= 0) stop "cannot open xml file"
33
34call xml_parse(fxml, begin_element_handler=begin_element_print)
35
36
37end program simple
Note: See TracBrowser for help on using the repository browser.