...
The interface to xml2eg_get
is: \begin{verbatim}
Code Block |
---|
subroutine xml2eg_get(xml2eg_document, path, out, errorflag) |
...
type(type_xml2eg_document) :: xml2eg_document |
...
character(len=*), intent(in) :: path |
...
<OutType>, intent(out) :: out |
...
logical, optional :: errorflag |
\end{verbatim}
Here \texttt{<OutType>
} is is either \texttt{integer
}, \texttt{integer, dimension(:)
}, \texttt{real(r4)
}, \texttt{real(r4) dimension(:)
}, \texttt{real(r8)
}, \texttt{real(r8), dimension(:)
}, , \texttt{boolean
}, \texttt{boolean, dimension(:)
}, , \texttt{character(:)
}, where \texttt{r4} and \texttt{r8} are r4
and r8
are defined in the module \texttt{xmllib
\_types
}.
The most simple usage of xml2eg is then:\begin{verbatim}
Code Block |
---|
use xml2eg_mdl, only: xml2eg_parse_memory, xml2eg_get, & |
...
type_xml2eg_document |
...
type(type_xml2eg_document) :: doc |
...
character(len=132), dimension(:), pointer ::parameters |
...
integer :: val |
...
call xml2eg_parse_memory( parameters , doc ) |
...
call xml2eg_get(doc , 'tree/branch/leaf' , val) |
...
|
The xml2eg
interface interface also includes error handling. When calling \texttt{xml2eg
\_get
} one one may provide a fourth (optional) argument, which is a output argument that returns a boolean error flag (true is the reading failed and false it is was successful). \begin{verbatim}
Code Block |
---|
logical :: execution_error |
...
... |
...
call xml2eg_get(doc , 'tree/branch/leaf' , val, execution_error) |
...
if (execution_error) then |
...
... |
...
end if |
\end{verbatim}Once finished reading the xml-document all allocated data has to be freed. This is achieved by calling \texttt{xml2eg
\_free
\_doc
}.\begin{verbatim}
Code Block |
---|
call xml2eg_free_doc(doc) |
...