C# Class HtmlAgilityPack.HtmlNode

Inheritance: IXPathNavigable
Mostrar archivo Open project: o2platform/O2.Platform.Projects Class Usage Examples

Public Properties

Property Type Description
ElementsFlags System.Collections.Hashtable
HtmlNodeTypeNameComment string
HtmlNodeTypeNameDocument string
HtmlNodeTypeNameText string

Private Properties

Property Type Description
CloseNode void
GetId string
GetXmlComment string
HtmlNode System
HtmlNode System
SetId void
WriteAttribute void
WriteAttributes void
WriteAttributes void

Public Methods

Method Description
AppendChild ( HtmlNode newChild ) : HtmlNode

Adds the specified node to the end of the list of children of this node.

AppendChildren ( HtmlAgilityPack.HtmlNodeCollection newChildren ) : void

Adds the specified node to the end of the list of children of this node.

CanOverlapElement ( string name ) : bool

Determines if an element node can be kept overlapped.

Clone ( ) : HtmlNode

Creates a duplicate of the node

CloneNode ( bool deep ) : HtmlNode

Creates a duplicate of the node.

CloneNode ( string newName ) : HtmlNode

Creates a duplicate of the node and changes its name at the same time.

CloneNode ( string newName, bool deep ) : HtmlNode

Creates a duplicate of the node and changes its name at the same time.

CopyFrom ( HtmlNode node ) : void

Creates a duplicate of the node and the subtree under it.

CopyFrom ( HtmlNode node, bool deep ) : void

Creates a duplicate of the node.

CreateNavigator ( ) : XPathNavigator

Creates a new XPathNavigator object for navigating this HTML node.

CreateNode ( string html ) : HtmlNode

Creates an HTML node from a string representing literal HTML.

GetAttributeValue ( string name, bool def ) : bool

Helper method to get the value of an attribute of this node. If the attribute is not found, the default value will be returned.

GetAttributeValue ( string name, int def ) : int

Helper method to get the value of an attribute of this node. If the attribute is not found, the default value will be returned.

GetAttributeValue ( string name, string def ) : string

Helper method to get the value of an attribute of this node. If the attribute is not found, the default value will be returned.

InsertAfter ( HtmlNode newChild, HtmlNode refChild ) : HtmlNode

Inserts the specified node immediately after the specified reference node.

InsertBefore ( HtmlNode newChild, HtmlNode refChild ) : HtmlNode

Inserts the specified node immediately before the specified reference node.

IsCDataElement ( string name ) : bool

Determines if an element node is a CDATA element node.

IsClosedElement ( string name ) : bool

Determines if an element node is closed.

IsEmptyElement ( string name ) : bool

Determines if an element node is defined as empty.

IsOverlappedClosingElement ( string text ) : bool

Determines if a text corresponds to the closing tag of an node that can be kept overlapped.

PrependChild ( HtmlNode newChild ) : HtmlNode

Adds the specified node to the beginning of the list of children of this node.

PrependChildren ( HtmlAgilityPack.HtmlNodeCollection newChildren ) : void

Adds the specified node list to the beginning of the list of children of this node.

RemoveAll ( ) : void

Removes all the children and/or attributes of the current node.

RemoveAllChildren ( ) : void

Removes all the children of the current node.

RemoveChild ( HtmlNode oldChild ) : HtmlNode

Removes the specified child node.

RemoveChild ( HtmlNode oldChild, bool keepGrandChildren ) : HtmlNode

Removes the specified child node.

ReplaceChild ( HtmlNode newChild, HtmlNode oldChild ) : HtmlNode

Replaces the child node oldChild with newChild node.

SelectNodes ( string xpath ) : HtmlAgilityPack.HtmlNodeCollection

Selects a list of nodes matching the XPath expression.

SelectSingleNode ( string xpath ) : HtmlNode

Selects the first XmlNode that matches the XPath expression.

SetAttributeValue ( string name, string value ) : HtmlAgilityPack.HtmlAttribute

Helper method to set the value of an attribute of this node. If the attribute is not found, it will be created automatically.

WriteContentTo ( ) : string

Saves all the children of the node to a string.

WriteContentTo ( TextWriter outText ) : void

Saves all the children of the node to the specified TextWriter.

WriteTo ( ) : string

Saves the current node to a string.

WriteTo ( TextWriter outText ) : void

Saves the current node to the specified TextWriter.

WriteTo ( XmlWriter writer ) : void

Saves the current node to the specified XmlWriter.

Private Methods

Method Description
CloseNode ( HtmlNode endnode ) : void
GetId ( ) : string
GetXmlComment ( HtmlAgilityPack.HtmlCommentNode comment ) : string
HtmlNode ( ) : System
HtmlNode ( HtmlNodeType type, HtmlAgilityPack.HtmlDocument ownerdocument, int index ) : System
SetId ( string id ) : void
WriteAttribute ( TextWriter outText, HtmlAgilityPack.HtmlAttribute att ) : void
WriteAttributes ( TextWriter outText, bool closing ) : void
WriteAttributes ( XmlWriter writer, HtmlNode node ) : void

Method Details

AppendChild() public method

Adds the specified node to the end of the list of children of this node.
public AppendChild ( HtmlNode newChild ) : HtmlNode
newChild HtmlNode The node to add. May not be null.
return HtmlNode

AppendChildren() public method

Adds the specified node to the end of the list of children of this node.
public AppendChildren ( HtmlAgilityPack.HtmlNodeCollection newChildren ) : void
newChildren HtmlAgilityPack.HtmlNodeCollection The node list to add. May not be null.
return void

CanOverlapElement() public static method

Determines if an element node can be kept overlapped.
public static CanOverlapElement ( string name ) : bool
name string The name of the element node to check. May not be null.
return bool

Clone() public method

Creates a duplicate of the node
public Clone ( ) : HtmlNode
return HtmlNode

CloneNode() public method

Creates a duplicate of the node.
public CloneNode ( bool deep ) : HtmlNode
deep bool true to recursively clone the subtree under the specified node; false to clone only the node itself.
return HtmlNode

CloneNode() public method

Creates a duplicate of the node and changes its name at the same time.
public CloneNode ( string newName ) : HtmlNode
newName string The new name of the cloned node. May not be null.
return HtmlNode

CloneNode() public method

Creates a duplicate of the node and changes its name at the same time.
public CloneNode ( string newName, bool deep ) : HtmlNode
newName string The new name of the cloned node. May not be null.
deep bool true to recursively clone the subtree under the specified node; false to clone only the node itself.
return HtmlNode

CopyFrom() public method

Creates a duplicate of the node and the subtree under it.
public CopyFrom ( HtmlNode node ) : void
node HtmlNode The node to duplicate. May not be null.
return void

CopyFrom() public method

Creates a duplicate of the node.
public CopyFrom ( HtmlNode node, bool deep ) : void
node HtmlNode The node to duplicate. May not be null.
deep bool true to recursively clone the subtree under the specified node, false to clone only the node itself.
return void

CreateNavigator() public method

Creates a new XPathNavigator object for navigating this HTML node.
public CreateNavigator ( ) : XPathNavigator
return System.Xml.XPath.XPathNavigator

CreateNode() public static method

Creates an HTML node from a string representing literal HTML.
public static CreateNode ( string html ) : HtmlNode
html string The HTML text.
return HtmlNode

GetAttributeValue() public method

Helper method to get the value of an attribute of this node. If the attribute is not found, the default value will be returned.
public GetAttributeValue ( string name, bool def ) : bool
name string The name of the attribute to get. May not be null.
def bool The default value to return if not found.
return bool

GetAttributeValue() public method

Helper method to get the value of an attribute of this node. If the attribute is not found, the default value will be returned.
public GetAttributeValue ( string name, int def ) : int
name string The name of the attribute to get. May not be null.
def int The default value to return if not found.
return int

GetAttributeValue() public method

Helper method to get the value of an attribute of this node. If the attribute is not found, the default value will be returned.
public GetAttributeValue ( string name, string def ) : string
name string The name of the attribute to get. May not be null.
def string The default value to return if not found.
return string

InsertAfter() public method

Inserts the specified node immediately after the specified reference node.
public InsertAfter ( HtmlNode newChild, HtmlNode refChild ) : HtmlNode
newChild HtmlNode The node to insert. May not be null.
refChild HtmlNode The node that is the reference node. The newNode is placed after the refNode.
return HtmlNode

InsertBefore() public method

Inserts the specified node immediately before the specified reference node.
public InsertBefore ( HtmlNode newChild, HtmlNode refChild ) : HtmlNode
newChild HtmlNode The node to insert. May not be null.
refChild HtmlNode The node that is the reference node. The newChild is placed before this node.
return HtmlNode

IsCDataElement() public static method

Determines if an element node is a CDATA element node.
public static IsCDataElement ( string name ) : bool
name string The name of the element node to check. May not be null.
return bool

IsClosedElement() public static method

Determines if an element node is closed.
public static IsClosedElement ( string name ) : bool
name string The name of the element node to check. May not be null.
return bool

IsEmptyElement() public static method

Determines if an element node is defined as empty.
public static IsEmptyElement ( string name ) : bool
name string The name of the element node to check. May not be null.
return bool

IsOverlappedClosingElement() public static method

Determines if a text corresponds to the closing tag of an node that can be kept overlapped.
public static IsOverlappedClosingElement ( string text ) : bool
text string The text to check. May not be null.
return bool

PrependChild() public method

Adds the specified node to the beginning of the list of children of this node.
public PrependChild ( HtmlNode newChild ) : HtmlNode
newChild HtmlNode The node to add. May not be null.
return HtmlNode

PrependChildren() public method

Adds the specified node list to the beginning of the list of children of this node.
public PrependChildren ( HtmlAgilityPack.HtmlNodeCollection newChildren ) : void
newChildren HtmlAgilityPack.HtmlNodeCollection The node list to add. May not be null.
return void

RemoveAll() public method

Removes all the children and/or attributes of the current node.
public RemoveAll ( ) : void
return void

RemoveAllChildren() public method

Removes all the children of the current node.
public RemoveAllChildren ( ) : void
return void

RemoveChild() public method

Removes the specified child node.
public RemoveChild ( HtmlNode oldChild ) : HtmlNode
oldChild HtmlNode The node being removed. May not be null.
return HtmlNode

RemoveChild() public method

Removes the specified child node.
public RemoveChild ( HtmlNode oldChild, bool keepGrandChildren ) : HtmlNode
oldChild HtmlNode The node being removed. May not be null.
keepGrandChildren bool true to keep grand children of the node, false otherwise.
return HtmlNode

ReplaceChild() public method

Replaces the child node oldChild with newChild node.
public ReplaceChild ( HtmlNode newChild, HtmlNode oldChild ) : HtmlNode
newChild HtmlNode The new node to put in the child list.
oldChild HtmlNode The node being replaced in the list.
return HtmlNode

SelectNodes() public method

Selects a list of nodes matching the XPath expression.
public SelectNodes ( string xpath ) : HtmlAgilityPack.HtmlNodeCollection
xpath string The XPath expression.
return HtmlAgilityPack.HtmlNodeCollection

SelectSingleNode() public method

Selects the first XmlNode that matches the XPath expression.
public SelectSingleNode ( string xpath ) : HtmlNode
xpath string The XPath expression. May not be null.
return HtmlNode

SetAttributeValue() public method

Helper method to set the value of an attribute of this node. If the attribute is not found, it will be created automatically.
public SetAttributeValue ( string name, string value ) : HtmlAgilityPack.HtmlAttribute
name string The name of the attribute to set. May not be null.
value string The value for the attribute.
return HtmlAgilityPack.HtmlAttribute

WriteContentTo() public method

Saves all the children of the node to a string.
public WriteContentTo ( ) : string
return string

WriteContentTo() public method

Saves all the children of the node to the specified TextWriter.
public WriteContentTo ( TextWriter outText ) : void
outText System.IO.TextWriter The TextWriter to which you want to save.
return void

WriteTo() public method

Saves the current node to a string.
public WriteTo ( ) : string
return string

WriteTo() public method

Saves the current node to the specified TextWriter.
public WriteTo ( TextWriter outText ) : void
outText System.IO.TextWriter The TextWriter to which you want to save.
return void

WriteTo() public method

Saves the current node to the specified XmlWriter.
public WriteTo ( XmlWriter writer ) : void
writer System.Xml.XmlWriter The XmlWriter to which you want to save.
return void

Property Details

ElementsFlags public_oe static_oe property

Gets a collection of flags that define specific behaviors for specific element nodes. The table contains a DictionaryEntry list with the lowercase tag name as the Key, and a combination of HtmlElementFlags as the Value.
public static Hashtable,System.Collections ElementsFlags
return System.Collections.Hashtable

HtmlNodeTypeNameComment public_oe static_oe property

Gets the name of a comment node. It is actually defined as '#comment'.
public static string HtmlNodeTypeNameComment
return string

HtmlNodeTypeNameDocument public_oe static_oe property

Gets the name of the document node. It is actually defined as '#document'.
public static string HtmlNodeTypeNameDocument
return string

HtmlNodeTypeNameText public_oe static_oe property

Gets the name of a text node. It is actually defined as '#text'.
public static string HtmlNodeTypeNameText
return string