New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
context.f90 in vendors/XMLF90/current/doc/Tutorial/xpath – NEMO

source: vendors/XMLF90/current/doc/Tutorial/xpath/context.f90 @ 1967

Last change on this file since 1967 was 1967, checked in by flavoni, 14 years ago

importing XMLF90 vendor

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.