C# Class Microsoft.Html.Core.Tree.Nodes.ElementNode

Represent HTML element node in the tree
Inheritance: TreeNode, ICompositeTextRange, IHtmlTreeVisitorPattern, IPropertyOwner
ファイルを表示 Open project: Microsoft/RTVS Class Usage Examples

Public Methods

Method Description
Accept ( Func visitor, object parameter ) : bool
Accept ( IHtmlTreeVisitor visitor, object parameter ) : bool
AddOrphanedEndTag ( TagNode tag ) : void
Contains ( ITextRange range, bool inclusiveTagStart, bool inclusiveTagEnd ) : bool
Contains ( int position ) : bool

Determines if element contains given position

ElementEnclosingRange ( ITextRange range, bool inclusiveEnd ) : ElementNode

Finds deepest element node which inner range fully encloses given positions

ElementFromPosition ( int pos ) : ElementNode

Finds deepest element node that contains given position

ElementFromRange ( ITextRange range ) : ElementNode

Finds deepest element node that fully encloses given range

ElementFromRangeAndInclusion ( ITextRange range, bool inclusiveTagStart, bool inclusiveTagEnd ) : ElementNode
ElementNode ( ElementNode parent, int openAngleBracketPosition, NameToken nameToken, int maxEnd ) : System
GetAttribute ( string attributeName ) : AttributeNode

Locates element attribute by name using string comparison as specified by tree the element is in.

GetAttribute ( string attributeName, bool ignoreCase ) : AttributeNode

Locates element attribute by name

GetAttribute ( string prefix, string attributeName, bool ignoreCase ) : AttributeNode

Locates element attribute by prefix and name

GetAttributeIndex ( string attributeName, bool ignoreCase ) : int

Locates element attribute by name

GetChildrenSurroundingRange ( ITextRange range, int &child1, int &child2 ) : void

Given text range locates previous and next child nodes that surround the range

GetCommonAncestor ( ElementNode node1, ElementNode node2 ) : ElementNode

Retrieves node that contains both node1 and node2 ranges. Node1 range must precede node2 in the text buffer

GetPositionElement ( int position, ElementNode &element, AttributeNode &attribute ) : HtmlPositionType

Determines position type and enclosing element node for a given position in the document text.

GetText ( ITextRange range ) : string
HasPrefix ( ) : bool
IsDocType ( ) : bool

Determines if element is a DOCTYPE element

IsScriptBlock ( ) : bool

Determines if element is a script block

IsSelfClosing ( ) : bool

Tells if element is self-closing element like <br>. Does not tell if element is closed by />, use IsShortHand for that.

IsShorthand ( ) : bool

Tells if element is a short-hand element ending in />

IsStyleBlock ( ) : bool

Determines if element is a style block

RemoveChild ( int index ) : void
RemoveChildren ( int start, int count ) : void
Shift ( int offset ) : void

Shifts node start, end and all child elements by the specified offset.

ShiftStartingFrom ( int start, int offset ) : void

Shifts node components that are located at or beyond given start point by the specified range

Private Methods

Method Description
CompleteElement ( ITextRange closingSequence, bool isClosed, ReadOnlyCollection children, ReadOnlyCollection startTagAtributes, ReadOnlyCollection endTagAttributes ) : void

Completes element. Called by tree builder when element is complete: start tag is self-closed or implicitly closed or element is closed by a well-formed end tag or by another tag that is being opened.

FindTopmostParent ( List tagNames, bool ignoreCase ) : ElementNode

Given list of end tag names finds topmost element that matches provided end tags

OpenEndTag ( int position, NameToken nameToken, int maxEnd ) : void

Begins element end tag processing. Called exclusively by tree builder. when it discovers </name sequence.

ToString ( ) : string

Method Details

Accept() public method

public Accept ( Func visitor, object parameter ) : bool
visitor Func
parameter object
return bool

Accept() public method

public Accept ( IHtmlTreeVisitor visitor, object parameter ) : bool
visitor IHtmlTreeVisitor
parameter object
return bool

AddOrphanedEndTag() public method

public AddOrphanedEndTag ( TagNode tag ) : void
tag TagNode
return void

Contains() public method

public Contains ( ITextRange range, bool inclusiveTagStart, bool inclusiveTagEnd ) : bool
range ITextRange
inclusiveTagStart bool
inclusiveTagEnd bool
return bool

Contains() public method

Determines if element contains given position
public Contains ( int position ) : bool
position int Position in a text buffer
return bool

ElementEnclosingRange() public method

Finds deepest element node which inner range fully encloses given positions
public ElementEnclosingRange ( ITextRange range, bool inclusiveEnd ) : ElementNode
range ITextRange Range to analyze
inclusiveEnd bool If true, element and range may have same end points
return ElementNode

ElementFromPosition() public method

Finds deepest element node that contains given position
public ElementFromPosition ( int pos ) : ElementNode
pos int Position
return ElementNode

ElementFromRange() public method

Finds deepest element node that fully encloses given range
public ElementFromRange ( ITextRange range ) : ElementNode
range ITextRange
return ElementNode

ElementFromRangeAndInclusion() public method

public ElementFromRangeAndInclusion ( ITextRange range, bool inclusiveTagStart, bool inclusiveTagEnd ) : ElementNode
range ITextRange
inclusiveTagStart bool
inclusiveTagEnd bool
return ElementNode

ElementNode() public method

public ElementNode ( ElementNode parent, int openAngleBracketPosition, NameToken nameToken, int maxEnd ) : System
parent ElementNode
openAngleBracketPosition int
nameToken Microsoft.Html.Core.Parser.Tokens.NameToken
maxEnd int
return System

GetAttribute() public method

Locates element attribute by name using string comparison as specified by tree the element is in.
public GetAttribute ( string attributeName ) : AttributeNode
attributeName string Fully qualified attribute name
return AttributeNode

GetAttribute() public method

Locates element attribute by name
public GetAttribute ( string attributeName, bool ignoreCase ) : AttributeNode
attributeName string Fully qualified attribute name
ignoreCase bool True if comparison should be case-insensitive
return AttributeNode

GetAttribute() public method

Locates element attribute by prefix and name
public GetAttribute ( string prefix, string attributeName, bool ignoreCase ) : AttributeNode
prefix string Namespace prefix
attributeName string Attribute name
ignoreCase bool True if comparison should be case-insensitive
return AttributeNode

GetAttributeIndex() public method

Locates element attribute by name
public GetAttributeIndex ( string attributeName, bool ignoreCase ) : int
attributeName string Fully qualified attribute name
ignoreCase bool True if comparison should be case-insensitive
return int

GetChildrenSurroundingRange() public method

Given text range locates previous and next child nodes that surround the range
public GetChildrenSurroundingRange ( ITextRange range, int &child1, int &child2 ) : void
range ITextRange Text range
child1 int Index of the child node that precedes start of the range
child2 int Index of the child that follows end of the range
return void

GetCommonAncestor() public method

Retrieves node that contains both node1 and node2 ranges. Node1 range must precede node2 in the text buffer
public GetCommonAncestor ( ElementNode node1, ElementNode node2 ) : ElementNode
node1 ElementNode First node
node2 ElementNode Second node
return ElementNode

GetPositionElement() public method

Determines position type and enclosing element node for a given position in the document text.
public GetPositionElement ( int position, ElementNode &element, AttributeNode &attribute ) : HtmlPositionType
position int Position in the document text
element ElementNode Element that contains position
attribute AttributeNode Attribute that contains position (may be null)
return HtmlPositionType

GetText() public method

public GetText ( ITextRange range ) : string
range ITextRange
return string

HasPrefix() public method

public HasPrefix ( ) : bool
return bool

IsDocType() public method

Determines if element is a DOCTYPE element
public IsDocType ( ) : bool
return bool

IsScriptBlock() public method

Determines if element is a script block
public IsScriptBlock ( ) : bool
return bool

IsSelfClosing() public method

Tells if element is self-closing element like <br>. Does not tell if element is closed by />, use IsShortHand for that.
public IsSelfClosing ( ) : bool
return bool

IsShorthand() public method

Tells if element is a short-hand element ending in />
public IsShorthand ( ) : bool
return bool

IsStyleBlock() public method

Determines if element is a style block
public IsStyleBlock ( ) : bool
return bool

RemoveChild() public method

public RemoveChild ( int index ) : void
index int
return void

RemoveChildren() public method

public RemoveChildren ( int start, int count ) : void
start int
count int
return void

Shift() public method

Shifts node start, end and all child elements by the specified offset.
public Shift ( int offset ) : void
offset int
return void

ShiftStartingFrom() public method

Shifts node components that are located at or beyond given start point by the specified range
public ShiftStartingFrom ( int start, int offset ) : void
start int Start point
offset int Offset to shift by
return void