program dom_open_errors_example
use FoX_dom
implicit none
type(Node), pointer :: myDoc
type(DOMException) :: ex
integer :: ios
myDoc => parseFile("h2o.xml", iostat=ios, ex=ex)
if (ios.ne.0) then
print*, "Problem reading file. iostat was ", ios
stop
elseif (inException(ex)) then
print*,"DOM Parse error ", getExceptionCode(ex)
stop
else
print*, "Not in exception and file read OK"
endif
! Do something with myDoc
end program dom_open_errors_example
Hopefully this works for you. You should see a DOM Parse error if the XML file exists but is not well-formed XML, and a non-zero iostat (strictly with a machine-specific meaning) if the file cannot be read. One oddity to note is that if ex is not present but ios is, you may end up with a FoX error code in ios. That only happens if the file exists but it not well-formed XML.
I'll add an annotated version of this to the examples directory.
Best wishes,
Andrew