C# Класс HtmlAgilityPack.HtmlNode

Наследование: IXPathNavigable
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
ElementsFlags System.Collections.Hashtable
HtmlNodeTypeNameComment string
HtmlNodeTypeNameDocument string
HtmlNodeTypeNameText string

Private Properties

Свойство Тип Описание
CloseNode void
GetId string
GetXmlComment string
HtmlNode System
HtmlNode System
SetId void
WriteAttribute void
WriteAttributes void
WriteAttributes void

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
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

Описание методов

AppendChild() публичный Метод

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.
Результат HtmlNode

AppendChildren() публичный Метод

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.
Результат void

CanOverlapElement() публичный статический Метод

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.
Результат bool

Clone() публичный Метод

Creates a duplicate of the node
public Clone ( ) : HtmlNode
Результат HtmlNode

CloneNode() публичный Метод

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.
Результат HtmlNode

CloneNode() публичный Метод

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.
Результат HtmlNode

CloneNode() публичный Метод

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.
Результат HtmlNode

CopyFrom() публичный Метод

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.
Результат void

CopyFrom() публичный Метод

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.
Результат void

CreateNavigator() публичный Метод

Creates a new XPathNavigator object for navigating this HTML node.
public CreateNavigator ( ) : XPathNavigator
Результат System.Xml.XPath.XPathNavigator

CreateNode() публичный статический Метод

Creates an HTML node from a string representing literal HTML.
public static CreateNode ( string html ) : HtmlNode
html string The HTML text.
Результат HtmlNode

GetAttributeValue() публичный Метод

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.
Результат bool

GetAttributeValue() публичный Метод

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.
Результат int

GetAttributeValue() публичный Метод

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.
Результат string

InsertAfter() публичный Метод

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.
Результат HtmlNode

InsertBefore() публичный Метод

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.
Результат HtmlNode

IsCDataElement() публичный статический Метод

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.
Результат bool

IsClosedElement() публичный статический Метод

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.
Результат bool

IsEmptyElement() публичный статический Метод

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.
Результат bool

IsOverlappedClosingElement() публичный статический Метод

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.
Результат bool

PrependChild() публичный Метод

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.
Результат HtmlNode

PrependChildren() публичный Метод

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.
Результат void

RemoveAll() публичный Метод

Removes all the children and/or attributes of the current node.
public RemoveAll ( ) : void
Результат void

RemoveAllChildren() публичный Метод

Removes all the children of the current node.
public RemoveAllChildren ( ) : void
Результат void

RemoveChild() публичный Метод

Removes the specified child node.
public RemoveChild ( HtmlNode oldChild ) : HtmlNode
oldChild HtmlNode The node being removed. May not be null.
Результат HtmlNode

RemoveChild() публичный Метод

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.
Результат HtmlNode

ReplaceChild() публичный Метод

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.
Результат HtmlNode

SelectNodes() публичный Метод

Selects a list of nodes matching the XPath expression.
public SelectNodes ( string xpath ) : HtmlAgilityPack.HtmlNodeCollection
xpath string The XPath expression.
Результат HtmlAgilityPack.HtmlNodeCollection

SelectSingleNode() публичный Метод

Selects the first XmlNode that matches the XPath expression.
public SelectSingleNode ( string xpath ) : HtmlNode
xpath string The XPath expression. May not be null.
Результат HtmlNode

SetAttributeValue() публичный Метод

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.
Результат HtmlAgilityPack.HtmlAttribute

WriteContentTo() публичный Метод

Saves all the children of the node to a string.
public WriteContentTo ( ) : string
Результат string

WriteContentTo() публичный Метод

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.
Результат void

WriteTo() публичный Метод

Saves the current node to a string.
public WriteTo ( ) : string
Результат string

WriteTo() публичный Метод

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.
Результат void

WriteTo() публичный Метод

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.
Результат void

Описание свойств

ElementsFlags публичное статическое свойство

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
Результат System.Collections.Hashtable

HtmlNodeTypeNameComment публичное статическое свойство

Gets the name of a comment node. It is actually defined as '#comment'.
public static string HtmlNodeTypeNameComment
Результат string

HtmlNodeTypeNameDocument публичное статическое свойство

Gets the name of the document node. It is actually defined as '#document'.
public static string HtmlNodeTypeNameDocument
Результат string

HtmlNodeTypeNameText публичное статическое свойство

Gets the name of a text node. It is actually defined as '#text'.
public static string HtmlNodeTypeNameText
Результат string