Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #r "System.Xml.dll"
- open System.Xml
- let clean (path:string) =
- let doc = XmlDocument()
- doc.Load(path)
- let post = doc.["post"]
- printfn "%s" post.["title"].InnerText
- let comments = post.["comments"]
- let approved, unapproved =
- [for comment in comments.ChildNodes -> comment]
- |> List.partition (fun comment ->
- XmlConvert.ToBoolean(comment.Attributes.["approved"].Value.ToLower())
- )
- printfn "Approved %d Spam %d" approved.Length unapproved.Length
- for comment in unapproved do
- comments.RemoveChild(comment) |> ignore
- doc.Save(path)
- open System.IO
- let files = Directory.EnumerateFiles(@"C:\Phil\posts", "*.xml") |> Seq.toArray
- for path in files do clean path
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement