Created
July 19, 2013 10:28
-
-
Save PatrickMcDonald/6038204 to your computer and use it in GitHub Desktop.
From examples in Real World Functional Programming
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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