source: XMLF90/doc/Tutorial/xpath/context.f90 @ 6

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

Import des sources XMLF90

File size: 909 bytes
Line 
1program item_context
2use flib_xpath
3type(xml_t) :: fxml, context
4integer :: status
5character(len=100) :: what, price, currency
6type(dictionary_t) :: attributes
7
8call open_xmlfile("inventory.xml",fxml,status)
9!
10do
11   call mark_node(fxml,path="//item",status=status)
12   if (status < 0) exit ! No more items
13   context = fxml ! Save item context
14!
15! Search relative to context
16!
17   call get_node(fxml,path="price", &
18        attributes=attributes,pcdata=price,status=status)
19   call get_value(attributes,"currency",currency,status)
20   if (status /= 0) stop "missing currency attribute!"
21!
22! Rewind to beginning of context
23
24   call sync_to_context(fxml,context)
25!
26! Search relative to context
27!
28   call get_node(fxml,path="description",pcdata=what,status=status)
29   write(unit=*,fmt="(6a))") "Appliance: ", trim(what), &
30        ". Price: ", trim(price), " ", trim(currency)
31enddo
32end program item_context
33
34
35
36
37
38
39
Note: See TracBrowser for help on using the repository browser.