Skip to content

Fortran-FOSS-Programmers/FoXy

Repository files navigation

FoXy

Fortran XML parser for poor people — a KISS pure Fortran 2008+ OOP library for parsing and emitting XML files and tags.

CI Coverage GitHub tag License


Features

  • Parse XML from a string or a file into a linearised DOM with full hierarchy tracking
  • Nested tags and repeated tags with the same name supported
  • Create tags programmatically with attributes, text content, and nesting
  • Emit tags to string or write atomically to a file unit
  • Self-closing tags, indentation, and partial emission (start / content / end separately)
  • Add and delete tags and attributes by name
  • OOP designed — two clean types (xml_tag, xml_file), all functionality as type-bound procedures
  • No C bindings, no wrappers — pure Fortran 2008+ with implicit none throughout
  • Multi build system: fpm, FoBiS.py, CMake

Documentation | API Reference


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.


Quick start

Parse an XML string and query a tag's content:

use foxy, only: xml_file
implicit none
type(xml_file)                :: xfile
character(len=:), allocatable :: val

call xfile%parse(string= &
  '<config>'//new_line('A')// &
  '  <dt unit="s">0.01</dt>'//new_line('A')// &
  '  <nstep>1000</nstep>'//new_line('A')// &
  '</config>')

val = xfile%content('dt')
print *, val   ! 0.01

Create and emit a tag programmatically:

use foxy, only: xml_tag
implicit none
type(xml_tag) :: tag

tag = xml_tag(name='point', &
              attributes=reshape([['x','1'],['y','2'],['z','3']], [2,3]))
print *, tag%stringify()   ! <point x="1" y="2" z="3"/>

Install

fpm (recommended)

Add FoXy as a dependency in your fpm.toml:

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

Clone and build with FoBiS.py

git clone --recursive https://github.com/Fortran-FOSS-Programmers/FoXy.git
cd FoXy
FoBiS.py build -mode tests-gnu && bash scripts/run_tests.sh

Clone and build with CMake

git clone --recursive https://github.com/Fortran-FOSS-Programmers/FoXy.git
cd FoXy
mkdir build && cd build
cmake ..
make && make install
Tool Command
fpm fpm build && fpm test
FoBiS.py FoBiS.py build -mode tests-gnu
CMake cmake .. && make

About

Fortran XML parser for poor people

Topics

Resources

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •