8 people like it.

HtmlAgilityPack.FSharp

An F# wrapper for HtmlAgilityPack

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
33: 
34: 
35: 
36: 
37: 
38: 
39: 
40: 
41: 
42: 
43: 
44: 
45: 
46: 
47: 
48: 
49: 
50: 
51: 
52: 
53: 
54: 
55: 
56: 
57: 
58: 
59: 
60: 
61: 
62: 
63: 
64: 
65: 
66: 
67: 
68: 
69: 
70: 
71: 
72: 
73: 
74: 
75: 
76: 
77: 
78: 
79: 
80: 
81: 
82: 
83: 
84: 
85: 
86: 
87: 
88: 
89: 
90: 
91: 
92: 
93: 
94: 
95: 
96: 
97: 
98: 
module HtmlAgilityPack.FSharp

open HtmlAgilityPack

type HtmlNode with 
    
    member x.FollowingSibling name = 
        let sibling = x.NextSibling
        if sibling = null then
            null
        elif sibling.Name = name then
            sibling
        else 
            sibling.FollowingSibling name
    
    member x.FollowingSiblings name = seq {
        let sibling = x.NextSibling
        if sibling <> null then
            if sibling.Name = name then
                yield sibling
            yield! sibling.FollowingSiblings name
    }

    member x.PrecedingSibling name = 
        let sibling = x.PreviousSibling
        if sibling = null then
            null
        elif sibling.Name = name then
            sibling
        else 
            sibling.PrecedingSibling name
    
    member x.PrecedingSiblings name = seq {
        let sibling = x.PreviousSibling
        if sibling <> null then
            if sibling.Name = name then
                yield sibling
            yield! sibling.PrecedingSiblings name
    }

let parent (node : HtmlNode) = 
    node.ParentNode

let element name (node : HtmlNode) = 
    node.Element name

let elements name (node : HtmlNode) = 
    node.Elements name

let descendants name (node : HtmlNode) = 
    node.Descendants name

let descendantsAndSelf name (node : HtmlNode) = 
    node.DescendantsAndSelf name

let ancestors name (node : HtmlNode) = 
    node.Ancestors name

let ancestorsAndSelf name (node : HtmlNode) = 
    node.AncestorsAndSelf name

let followingSibling name (node : HtmlNode) = 
    node.FollowingSibling name

let followingSiblings name (node : HtmlNode) = 
    node.FollowingSiblings name

let precedingSibling name (node : HtmlNode) = 
    node.PrecedingSibling name

let precedingSiblings name (node : HtmlNode) = 
    node.PrecedingSiblings name

let inline innerText (node : HtmlNode) = 
    node.InnerText

let inline attr name (node : HtmlNode) = 
    node.GetAttributeValue(name, "")

let inline (?) (node : HtmlNode) name = 
    attr name node

let inline hasAttr name value node = 
    attr name node = value

let inline hasId value node = 
    hasAttr "id" value node

let inline hasClass value node = 
    hasAttr "class" value node

let inline hasText value (node : HtmlNode) = 
    node.InnerText = value

let createDoc html =
    let doc = new HtmlDocument()
    doc.LoadHtml html
    doc.DocumentNode
namespace HtmlAgilityPack
module FSharp

from HtmlAgilityPack
Multiple items
type HtmlNode =
  new : type:HtmlNodeType * ownerdocument:HtmlDocument * index:int -> HtmlNode
  member Ancestors : unit -> IEnumerable<HtmlNode> + 1 overload
  member AncestorsAndSelf : unit -> IEnumerable<HtmlNode> + 1 overload
  member AppendChild : newChild:HtmlNode -> HtmlNode
  member AppendChildren : newChildren:HtmlNodeCollection -> unit
  member Attributes : HtmlAttributeCollection with get, set
  member ChildAttributes : name:string -> IEnumerable<HtmlAttribute>
  member ChildNodes : HtmlNodeCollection with get, set
  member Clone : unit -> HtmlNode
  member CloneNode : newName:string -> HtmlNode + 2 overloads
  ...

Full name: HtmlAgilityPack.HtmlNode

--------------------
HtmlNode(type: HtmlNodeType, ownerdocument: HtmlDocument, index: int) : unit
val x : HtmlNode
member HtmlNode.FollowingSibling : name:string -> HtmlNode

Full name: HtmlAgilityPack.FSharp.FollowingSibling
val name : string
val sibling : HtmlNode
property HtmlNode.NextSibling: HtmlNode
property HtmlNode.Name: string
member HtmlNode.FollowingSibling : name:string -> HtmlNode
member HtmlNode.FollowingSiblings : name:string -> seq<HtmlNode>

Full name: HtmlAgilityPack.FSharp.FollowingSiblings
Multiple items
val seq : sequence:seq<'T> -> seq<'T>

Full name: Microsoft.FSharp.Core.Operators.seq

--------------------
type seq<'T> = System.Collections.Generic.IEnumerable<'T>

Full name: Microsoft.FSharp.Collections.seq<_>
member HtmlNode.FollowingSiblings : name:string -> seq<HtmlNode>
member HtmlNode.PrecedingSibling : name:string -> HtmlNode

Full name: HtmlAgilityPack.FSharp.PrecedingSibling
property HtmlNode.PreviousSibling: HtmlNode
member HtmlNode.PrecedingSibling : name:string -> HtmlNode
member HtmlNode.PrecedingSiblings : name:string -> seq<HtmlNode>

Full name: HtmlAgilityPack.FSharp.PrecedingSiblings
member HtmlNode.PrecedingSiblings : name:string -> seq<HtmlNode>
val parent : node:HtmlNode -> HtmlNode

Full name: HtmlAgilityPack.FSharp.parent
val node : HtmlNode
property HtmlNode.ParentNode: HtmlNode
val element : name:string -> node:HtmlNode -> HtmlNode

Full name: HtmlAgilityPack.FSharp.element
HtmlNode.Element(name: string) : HtmlNode
val elements : name:string -> node:HtmlNode -> System.Collections.Generic.IEnumerable<HtmlNode>

Full name: HtmlAgilityPack.FSharp.elements
HtmlNode.Elements(name: string) : System.Collections.Generic.IEnumerable<HtmlNode>
val descendants : name:string -> node:HtmlNode -> System.Collections.Generic.IEnumerable<HtmlNode>

Full name: HtmlAgilityPack.FSharp.descendants
HtmlNode.Descendants() : System.Collections.Generic.IEnumerable<HtmlNode>
HtmlNode.Descendants(name: string) : System.Collections.Generic.IEnumerable<HtmlNode>
val descendantsAndSelf : name:string -> node:HtmlNode -> System.Collections.Generic.IEnumerable<HtmlNode>

Full name: HtmlAgilityPack.FSharp.descendantsAndSelf
HtmlNode.DescendantsAndSelf() : System.Collections.Generic.IEnumerable<HtmlNode>
HtmlNode.DescendantsAndSelf(name: string) : System.Collections.Generic.IEnumerable<HtmlNode>
val ancestors : name:string -> node:HtmlNode -> System.Collections.Generic.IEnumerable<HtmlNode>

Full name: HtmlAgilityPack.FSharp.ancestors
HtmlNode.Ancestors() : System.Collections.Generic.IEnumerable<HtmlNode>
HtmlNode.Ancestors(name: string) : System.Collections.Generic.IEnumerable<HtmlNode>
val ancestorsAndSelf : name:string -> node:HtmlNode -> System.Collections.Generic.IEnumerable<HtmlNode>

Full name: HtmlAgilityPack.FSharp.ancestorsAndSelf
HtmlNode.AncestorsAndSelf() : System.Collections.Generic.IEnumerable<HtmlNode>
HtmlNode.AncestorsAndSelf(name: string) : System.Collections.Generic.IEnumerable<HtmlNode>
val followingSibling : name:string -> node:HtmlNode -> HtmlNode

Full name: HtmlAgilityPack.FSharp.followingSibling
val followingSiblings : name:string -> node:HtmlNode -> seq<HtmlNode>

Full name: HtmlAgilityPack.FSharp.followingSiblings
val precedingSibling : name:string -> node:HtmlNode -> HtmlNode

Full name: HtmlAgilityPack.FSharp.precedingSibling
val precedingSiblings : name:string -> node:HtmlNode -> seq<HtmlNode>

Full name: HtmlAgilityPack.FSharp.precedingSiblings
val innerText : node:HtmlNode -> string

Full name: HtmlAgilityPack.FSharp.innerText
property HtmlNode.InnerText: string
val attr : name:string -> node:HtmlNode -> string

Full name: HtmlAgilityPack.FSharp.attr
HtmlNode.GetAttributeValue(name: string, def: bool) : bool
HtmlNode.GetAttributeValue(name: string, def: int) : int
HtmlNode.GetAttributeValue(name: string, def: string) : string
val hasAttr : name:string -> value:string -> node:HtmlNode -> bool

Full name: HtmlAgilityPack.FSharp.hasAttr
val value : string
val hasId : value:string -> node:HtmlNode -> bool

Full name: HtmlAgilityPack.FSharp.hasId
val hasClass : value:string -> node:HtmlNode -> bool

Full name: HtmlAgilityPack.FSharp.hasClass
val hasText : value:string -> node:HtmlNode -> bool

Full name: HtmlAgilityPack.FSharp.hasText
val createDoc : html:string -> HtmlNode

Full name: HtmlAgilityPack.FSharp.createDoc
val html : string
val doc : HtmlDocument
Multiple items
type HtmlDocument =
  new : unit -> HtmlDocument
  val OptionAddDebuggingAttributes : bool
  val OptionAutoCloseOnEnd : bool
  val OptionCheckSyntax : bool
  val OptionComputeChecksum : bool
  val OptionDefaultStreamEncoding : Encoding
  val OptionExtractErrorSourceText : bool
  val OptionExtractErrorSourceTextMaxLength : int
  val OptionFixNestedTags : bool
  val OptionOutputAsXml : bool
  ...

Full name: HtmlAgilityPack.HtmlDocument

--------------------
HtmlDocument() : unit
HtmlDocument.LoadHtml(html: string) : unit
property HtmlDocument.DocumentNode: HtmlNode
Raw view New version

More information

Link:http://fssnip.net/kr
Posted:6 years ago
Author:Gustavo Guerra
Tags: htmlagilitypack html