[Haskell-cafe] XML modification

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Wed Nov 23 11:14:20 CET 2011

Andrew Coppin <andrewcoppin at btinternet.com> writes:

> I've got a folder with about 80 XML files in it. I want to
> take each file and make specific modifications to it.
> (Mostly just finding specific attributes and changing their
> values to make then all consistent.)
> Now I guess it wouldn't take me /that/ long to code
> something from scratch. But does anybody have a better
> suggestion for tools or libraries that might be useful?


Before google earth exposed a facility for computing path
lengths, I wrote my own using HaXml. The guts of it look like

main …
         xml <- fmap (xmlParse filename) (readFile filename)
         print_path_length xml

print_path_length (Document _ _ content _)
    = print $ compute_length $ coordinate_string_to_list coordinate_string
      where coordinate_string
                = singleCString
                  . (txt `o` children `o` deep (tag "coordinates"))
                  $ (CElem content)

which gives some idea of the flavour.

Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2010-09-14)

More information about the Haskell-Cafe mailing list