Skip to content
Fortran-FOSS-ProgrammersPublic

About

Fortran XML parser for poor people

Topics

Resources

Contributing

Stars

33 stars

Watchers

8 watching

Forks

Repository files navigation

FoXy logo: a low-poly arctic fox whose eyes and white blaze read </>

FoXy

Fortran XML for poor people

GitHub tag GitHub issues CI Coverage License

Read, query, edit and write XML from modern Fortran: a DOM for documents, an index for huge files, a streaming parser with your own callbacks, a writer for any size. Pure Fortran 2008, one module: use foxy.

📄 Parse
Strings and files, read in chunks (over 2 GiB too); UTF-8, UTF-16, UTF-32, Latin-1; tolerant, the first problem with its line
🔎 Query
By name, path or parent; path expressions (select); regular expressions on names, contents, attributes
🔢 Typed values
Contents and attributes read and written as integers, reals, logicals, lists, with an error status
✏️ Edit and save
Change contents, attributes and names by tag ID; insert and delete tags; the prolog kept
🖋️ Write any size
xml_writer, element by element, to a file, a unit or memory; only well-formed XML
🗂️ Huge files
xml_index: the tags without their content, contents read on demand
📡 Streaming parser
xml_handler: your callbacks in source order, nothing stored
🆓 Free and portable
Pure Fortran 2008, no C; gfortran, ifx, nvfortran; fpm, FoBiS, CMake; GPLv3, BSD, MIT

a terminal session of fx, a tool built on FoXy: the tree of a case file, a value read as a number, a path expression, a regular expression, a malformed file and a UTF-16 file streamed through a handler

The tutorial, the cookbook and the reference are on the FoXy website.


Quick start

Read the settings of a case file as numbers:

use foxy
type(xml_file) :: doc
real(R8P)      :: dt
integer(I4P)   :: steps

call doc%parse(filename='case.xml')
call doc%get_content(id=doc%find(path='case/time/dt'), value=dt)
call doc%get_content(id=doc%find(path='case/time/steps'), value=steps)

Learn the rest in the tutorial, or find a task in the cookbook.


Install

fpm: add FoXy to your fpm.toml.

[dependencies]
FoXy = { git = "https://github.com/Fortran-FOSS-Programmers/FoXy" }

FoBiS: clone, fetch the dependencies, build the library (lib/libfoxy.a, modules in lib/mod) or the tests.

git clone https://github.com/Fortran-FOSS-Programmers/FoXy && cd FoXy
fobis fetch
fobis build --mode foxy-static-gnu
fobis build --mode tests-gnu && bash scripts/run_tests.sh

Then link your program to it:

gfortran -I lib/mod my_program.f90 lib/libfoxy.a -o my_program

CMake: fetch the dependencies first (fobis fetch), then cmake -S . -B build && cmake --build build.

See Installation for compilers and options.


Authors

Contributions are welcome — see the Contributing page.

Copyrights

This project is distributed under a multi-licensing system:

Anyone interested in using, developing, or contributing to FoXy is welcome — pick the license that best fits your needs.

About

Fortran XML parser for poor people

Topics

Resources

Contributing

Stars

33 stars

Watchers

8 watching

Forks

Releases

Packages

Used by

Contributors

Languages