I want to get access to the data of an XML file like
<?xml version="1.0"?>
<MY>
<Foo id="1" name="test">
<Argument name="a" />
</Foo>
<Foo id="2" name="test2">
<Argument name="a" />
<Argument name="b" />
</Foo>
<Other id="2" name="someOther"/>
</MY>
I want e.g. to read out each Foo with its Arguments, how can I do this with Haskell? (I would like to use the HaXml module)
I don’t know where to start.
I cannot find up to date documentation and examples for haXml.
There is however some documentation for HXT available.
I know that’s probably an overkill for your example, but anyway.
If you want to use tagsoup, perhaps the following answers might help:
xml-tree parser (Haskell) for graph-library
In Haskell how do you extract strings from an XML document?
Here is the documentation an examples for HXT:
http://www.haskell.org/haskellwiki/HXT/Conversion_of_Haskell_data_from/to_XML
http://www.haskell.org/haskellwiki/HXT
http://www.haskell.org/haskellwiki/HXT/Practical
http://en.wikibooks.org/wiki/Haskell/XML
Now the code using HXT.
(warning I am not sure if this is the correct way)
I followed the tutorial:
http://www.haskell.org/haskellwiki/HXT/Conversion_of_Haskell_data_from/to_XML
you need your xml file as “data.xml”
RESULT (you need you xml example as “data.xml”):