
On Sun, Jul 29, 2012 at 1:21 AM, C K Kashyap
Hi,
With the help of the cafe I've been able to write up the xml parser using parsec - https://github.com/ckkashyap/really-simple-xml-parser/blob/master/RSXP.hs
I am struggling with an idea though - How can I capture the parent element of each element as I parse? Is it possible or would I have to do a second pass to do the fixup?
What are you trying to do? Maybe you could give an example of what you'd like to produce? Generally speaking, having tree elements in a Haskell datatype point to their parent and their children is asking for trouble - it means you can't change any part of the tree without re-building the entire tree (otherwise your parent pointers point to the parent in the old version of the tree). If you're interested in complex traversals and transformation of XML trees, I like the cursor API here: http://hackage.haskell.org/packages/archive/xml/1.3.12/doc/html/Text-XML-Lig... HaXML is also popular for whole-tree queries and transformations. Antoine