使用xmlf90使用Fortran解析XML

使用xmlf90使用Fortran解析XML,xml,fortran,Xml,Fortran,我需要用Fortran程序解析XML文件。我正在评估,看看它是否对我的需求有用,但我在让用户手册中的示例问题发挥作用方面遇到了困难。该错误与类型不匹配有关: pcdata_chunk_handler=pcdata_chunk ) 1 Error: Type mismatch in argument 'pcdata_chunk_handler' at (1); passed REAL(4

我需要用Fortran程序解析XML文件。我正在评估,看看它是否对我的需求有用,但我在让用户手册中的示例问题发挥作用方面遇到了困难。该错误与类型不匹配有关:

                 pcdata_chunk_handler=pcdata_chunk )
                                      1
Error: Type mismatch in argument 'pcdata_chunk_handler' at (1); 
passed REAL(4) to UNKNOWN
我直接从用户手册中复制了这个示例。这是我的主程序,它调用xml解析器:

program inventory
use flib_sax
use m_handlers

type(xml_t) :: fxml     ! XML file object (opaque)
integer :: iostat

call open_xmlfile("inventory.xml",fxml,iostat)
if (iostat /= 0) stop "cannot open xml file"

call xml_parse(fxml, begin_element_handler=begin_element, &
                 end_element_handler=end_element,     &   
                 pcdata_chunk_handler=pcdata_chunk )

end program inventory
这是“m_处理程序”模块:

我分析的“inventory.xml”文件是:

<inventory>
<item id="003">
    <description>Washing machine</description>
    <price currency="euro">1500.00</price>
</item>
<item id="007">
    <description>Microwave oven</description>
    <price currency="euro">300.00</price>
</item>
<item id="011">
    <description>Dishwasher</description>
    <price currency="swedish crown">10000.00</price>
</item>
</inventory>

洗衣机
1500
微波炉
300
洗碗机
10000

如果我从“call xml\u parse”语句中去掉“pcdata\u chunk\u handler=pcdata\u chunk”参数,这个程序可以运行,但当然,输出中缺少描述和价格数据

在xmlf90的用户手册中,m_处理程序模块中存在错误。子例程“pcdata_chunk_handler”实际上应该命名为“pcdata_chunk”,因为这是在主程序中的“call xml_parse”语句的参数中调用的,也是在模块文件“public::begin_element,end_element,pcdata_chunk”顶部调用的

<inventory>
<item id="003">
    <description>Washing machine</description>
    <price currency="euro">1500.00</price>
</item>
<item id="007">
    <description>Microwave oven</description>
    <price currency="euro">300.00</price>
</item>
<item id="011">
    <description>Dishwasher</description>
    <price currency="swedish crown">10000.00</price>
</item>
</inventory>