Skip to content

Instantly share code, notes, and snippets.

@PatrickMcDonald
Created July 19, 2013 10:28
Show Gist options
  • Save PatrickMcDonald/6038204 to your computer and use it in GitHub Desktop.
Save PatrickMcDonald/6038204 to your computer and use it in GitHub Desktop.
From examples in Real World Functional Programming
module XmlHelpers
open System.Xml.Linq
let wb = "http://www.worldbank.org"
let xattr s (el:XElement) =
el.Attribute(XName.Get(s)).Value
let xelem s (el:XContainer) =
el.Element(XName.Get(s, wb))
let xvalue (el:XElement) =
el.Value
let xelems s (el:XContainer) =
el.Elements(XName.Get(s, wb))
let xnested path (el:XContainer) =
let res = path |> Seq.fold (fun xn s ->
let child = xelem s xn
child :> XContainer) el
res :?> XElement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment