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.
i.self.f90 in vendors/XMLF90/current/doc/Tutorial/xpath – NEMO

source: vendors/XMLF90/current/doc/Tutorial/xpath/i.self.f90 @ 1960

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

importing XMLF90 r_53 vendor

File size: 1.3 KB
Line 
1program self
2use flib_xpath
3!
4! Example of re-scanning of an element
5!
6type(xml_t) :: fxml
7type(dictionary_t) :: attributes
8
9integer  :: status
10character(len=100)  :: id, currency, price
11
12call open_xmlfile("inventory.xml",fxml,status)
13!
14do
15      call mark_node(fxml,path="//item",status=status)
16      if (status < 0)   exit
17      !
18      ! Pretend we forgot to get the id attribute...
19      !
20      call get_node(fxml,path=".",attributes=attributes,status=status)
21      if (status < 0)   exit
22      call get_value(attributes,"id",id,status)
23      if (status /= 0) stop "missing id attribute!"
24      print *, "Id: ", trim(id)
25      !
26      ! Now perform a relative search in two stages:
27      !  First the attributes...
28      !
29      call get_node(fxml,path="price",attributes=attributes,status=status)
30      if (status < 0)   exit
31      call get_value(attributes,"currency",currency,status)
32      if (status /= 0) stop "missing currency attribute!"
33      print *, "Currency: ", trim(id)
34
35      !  And then the pcdata. Note that "." refers now to the /item/price
36      !  element, since fxml has been running through the file and we
37      !  have not saved any context to get back to.
38      !
39      call get_node(fxml,path=".",pcdata=price,status=status)
40      if (status /= 0) stop "error in retrieving price data"
41      print *, "Price: ", trim(price)
42enddo
43end program self
Note: See TracBrowser for help on using the repository browser.