Skip to content

Instantly share code, notes, and snippets.

@raimohanska
Created December 12, 2011 12:46
Show Gist options
  • Save raimohanska/1466986 to your computer and use it in GitHub Desktop.
Save raimohanska/1466986 to your computer and use it in GitHub Desktop.
Clean whitespace from XML
import Text.Regex.XMLSchema.String(match, sed)
clean :: String -> String
clean = sed (const "><") ">\\s*<" . trim
where trim = dropWhile whitespace . reverse . dropWhile whitespace . reverse
whitespace c = match "\\s" [c]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment