C# Class CsQuery.CQ

ファイルを表示 Open project: prepare/HTML-Renderer Class Usage Examples

Public Methods

Method Description
After ( IDomObject element ) : CQ

Insert an element, specified by the parameter, after each element in the set of matched elements.

After ( IEnumerable elements ) : CQ

Insert elements, specified by the parameter, after each element in the set of matched elements.

After ( string selector ) : CQ

Insert content, specified by the parameter, after each element in the set of matched elements.

Append ( ) : CQ

Insert content, specified by the parameter, to the end of each element in the set of matched elements.

Append ( Func func ) : CQ

Insert content, specified by the parameter, to the end of each element in the set of matched elements.

Append ( Func func ) : CQ

Insert content, specified by the parameter, to the end of each element in the set of matched elements.

Append ( Func func ) : CQ

Appends a func.

Append ( IDomObject element ) : CQ

Insert the element, specified by the parameter, to the end of each element in the set of matched elements.

Append ( IEnumerable elements ) : CQ

Insert the sequence of elements, specified by the parameter, to the end of each element in the set of matched elements.

CQ ( ) : System

Creates a new, empty CQ object.

CQ ( IDomObject element ) : System

Create a new CQ object wrapping a single element.

This differs from the CQ.Create(IDomObject) method in that this document is still related to its owning document; this is the same as if the element had just been selected. The Create method, conversely, creates an entirely new Document context contining a single element (a clone of this element).

CQ ( IDomObject element, CQ context ) : System

Create a new CQ object wrapping a single DOM element, in the context of another CQ object.

This differs from the overload accepting a single IDomObject parameter in that it associates the new object with a previous object, as if it were part of a selector chain. In practice this will rarely make a difference, but some methods such as CQ.End use this information.

CQ ( IEnumerable elements ) : System

Create a new CsQuery object wrapping an existing sequence of elements.

CQ ( IEnumerable elements, CQ context ) : System

Create a new CsQuery object from a set of DOM elements, assigning the 2nd parameter as a context for this object.

CQ ( System.Stream html, Encoding encoding, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default ) : System

Create a new CQ object from an HTML stream. CQ.Create(char[])

CQ ( System.Text.TextReader html, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default ) : System

Create a new CQ object from an HTML string.

CQ ( string selector, CQ context ) : System

Create a new CsQuery object using an existing instance and a selector. if the selector is null or missing, then it will contain no selection results.

CQ ( string html, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default ) : System

Create a new CQ object from an HTML string.

CQ ( string selector, object css, CQ context ) : System

Create a new CsQuery object from a selector or HTML, and assign CSS, within a context.

CQ ( string selector, string cssJson, CQ context ) : System

Create a new CsQuery object from a selector HTML, and assign CSS from a JSON string, within a context.

Create ( ) : CQ

Create an empty CQ object.

Create ( IDomObject element ) : CQ

Create a new CQ object from a single element. Unlike the constructor method CsQuery.CQ this new objet is not bound to any context from the element.

Create ( IEnumerable elements ) : CQ

Creeate a new CQ object from a squence of elements, or another CQ object. The new object will contain clones of the original objects; they are no longer bound to their owning context. If you want to wrap these elements and retain their context, use "new CQ(...)" instead.

Create ( System.Stream html ) : CQ

Create a new CQ object from a stream of HTML text, attempting to automatically detect the character set encoding from BOM.

Create ( System.Stream html, Encoding encoding ) : CQ

Create a new CQ from a stream of HTML text in the specified encoding.

Create ( System.Stream html, Encoding encoding = null, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default ) : CQ

Create a new CQ object from a stream of HTML, treating the HTML as a content document.

Create ( System.Text.TextReader html ) : CQ

Create a new CQ object from a TextReader containing HTML.

Create ( System.Text.TextReader html, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default ) : CQ

Create a new CQ object from a TextReader containg HTML

Create ( char html ) : CQ

Create a new CQ object from an HTML character array. Node: this method is obsolete; it may be removed in a future release. Character arrays were supported in prior versions because this was how all data was converted internally; this is not the case any more, and it's an unlikely format for typical input. Use string or stream methods instead.

Create ( string html ) : CQ

Create a new CQ object from a single element. Unlike the constructor method CsQuery.CQ this new objet is not bound to any context from the element.

Create ( string html, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default ) : CQ

Creeate a new CQ object from an HTML string.

Create ( string html, object quickSet ) : CQ

Create a new CQ from an HTML fragment, and use quickSet to create attributes (and/or css)

CreateDocument ( System.Stream html ) : CQ

Creates a new DOM from a stream containing HTML

CreateDocument ( System.Stream html, Encoding encoding ) : CQ

Creeate a new DOM from HTML text using full HTML5 tag generation.

CreateDocument ( System.Text.TextReader html ) : CQ

Creates a new DOM from a stream containing HTML

CreateDocument ( string html ) : CQ

Creeate a new DOM from HTML text using full HTML5 tag generation.

CreateDocumentFromFile ( string htmlFile ) : CQ

Creates a new DOM from an HTML file.

CreateFragment ( IEnumerable elements ) : CQ

Create a new CQ object from a sequence of elements, or another CQ object.

CreateFragment ( string html ) : CQ

Create a new fragment from a TextReader containing HTML text.

CreateFragment ( string html, string context ) : CQ

Creeate a new fragment from HTML text, in the context of a specific HTML tag.

CreateFromFile ( string htmlFile ) : CQ

Creates a new DOM from an HTML file.

Protected Methods

Method Description
CreateNew ( CQ target, System.Stream html, Encoding encoding, HtmlParsingMode parsingMode, HtmlParsingOptions parsingOptions, DocType docType ) : void

Bind this instance to a new DomFragment created from HTML in a specific HTML tag context.

CreateNewDocument ( ) : void

Bind this instance to a new empty DomDocument configured with the default options.

CreateNewFragment ( ) : void

Bind this instance to a new empty DomFragment configured with the default options.

CreateNewFragment ( CQ target, string html, string context, DocType docType ) : void

Bind this instance to a new DomFragment created from HTML using the specified parsing mode and element context

CreateNewFragment ( IEnumerable elements ) : void

Bind this instance to a new DomFragment created from a sequence of elements.

InsertAtOffset ( CQ target, int offset, CQ &insertedElements ) : CQ

Insert every element in the selection at or after the index of each target (adding offset to the index). If there is more than one target, the a clone is made of the selection for the 2nd and later targets.

This is a helper for Before and After. There is special handling when the target is not part of a DOM. Instead of altering the DOM, this method will alter the selection set, and return a CQ object that contains the new sequence. Normally, it would return the same CQ object (but alter the DOM).

InsertAtOffset ( IEnumerable target, int offset ) : CQ

Inserts an element at the specified offset from a target. Helper method for Before and After.

Private Methods

Method Description
Append ( IEnumerable elements, CQ &insertedElements ) : CQ

Append each element passed by parameter to each element in the selection set. The inserted elements are returned.

ConfigureNewInstance ( CQ dom, IDomObject element, CQ context ) : void
ConfigureNewInstance ( CQ dom, IEnumerable elements ) : void
ConfigureNewInstance ( CQ dom, IEnumerable elements, CQ context ) : void

Configures a new instance for a sequence of elements and an existing context.

ConfigureNewInstance ( string selector, CQ context ) : void

Configures a new instance for a sequence of elements and an existing context.

GetTrueTarget ( IDomElement target ) : IDomElement

Deals with tbody as the target of appends.

NewInstance ( IDomObject element, CQ context ) : CQ
NewInstance ( IEnumerable elements ) : CQ
NewInstance ( IEnumerable elements, CQ context ) : CQ
NewInstance ( string html ) : CQ

Method Details

After() public method

Insert an element, specified by the parameter, after each element in the set of matched elements.
public After ( IDomObject element ) : CQ
element IDomObject /// The element to insert. ///
return CQ

After() public method

Insert elements, specified by the parameter, after each element in the set of matched elements.
public After ( IEnumerable elements ) : CQ
elements IEnumerable /// The elements to insert. ///
return CQ

After() public method

Insert content, specified by the parameter, after each element in the set of matched elements.
public After ( string selector ) : CQ
selector string /// A CSS selector that determines the elements to insert. ///
return CQ

Append() public method

Insert content, specified by the parameter, to the end of each element in the set of matched elements.
public Append ( ) : CQ
return CQ

Append() public method

Insert content, specified by the parameter, to the end of each element in the set of matched elements.
public Append ( Func func ) : CQ
func Func /// A delegate to a function that returns a sequence of IDomElement objects to insert at the end /// of each element in the set of matched elements. Receives the index position of the element in /// the set and the old HTML value of the element as arguments. Within the function, this refers /// to the current element in the set. ///
return CQ

Append() public method

Insert content, specified by the parameter, to the end of each element in the set of matched elements.
public Append ( Func func ) : CQ
func Func /// A delegate to a function that returns an IDomElement to insert at the end of each element in /// the set of matched elements. Receives the index position of the element in the set and the /// old HTML value of the element as arguments. Within the function, this refers to the current /// element in the set. ///
return CQ

Append() public method

Appends a func.
public Append ( Func func ) : CQ
func Func /// A delegate to a function that returns an HTML string to insert at the end /// of each element in the set of matched elements. Receives the index position of the element in /// the set and the old HTML value of the element as arguments. Within the function, this refers /// to the current element in the set. ///
return CQ

Append() public method

Insert the element, specified by the parameter, to the end of each element in the set of matched elements.
public Append ( IDomObject element ) : CQ
element IDomObject /// The element to exclude. ///
return CQ

Append() public method

Insert the sequence of elements, specified by the parameter, to the end of each element in the set of matched elements.
public Append ( IEnumerable elements ) : CQ
elements IEnumerable /// The elements to be excluded. ///
return CQ

CQ() public method

Creates a new, empty CQ object.
public CQ ( ) : System
return System

CQ() public method

Create a new CQ object wrapping a single element.
This differs from the CQ.Create(IDomObject) method in that this document is still related to its owning document; this is the same as if the element had just been selected. The Create method, conversely, creates an entirely new Document context contining a single element (a clone of this element).
public CQ ( IDomObject element ) : System
element IDomObject /// The element. ///
return System

CQ() public method

Create a new CQ object wrapping a single DOM element, in the context of another CQ object.
This differs from the overload accepting a single IDomObject parameter in that it associates the new object with a previous object, as if it were part of a selector chain. In practice this will rarely make a difference, but some methods such as CQ.End use this information.
public CQ ( IDomObject element, CQ context ) : System
element IDomObject /// The element to wrap. ///
context CQ /// The context. ///
return System

CQ() public method

Create a new CsQuery object wrapping an existing sequence of elements.
public CQ ( IEnumerable elements ) : System
elements IEnumerable /// A sequence of elements to populate the object ///
return System

CQ() public method

Create a new CsQuery object from a set of DOM elements, assigning the 2nd parameter as a context for this object.
public CQ ( IEnumerable elements, CQ context ) : System
elements IEnumerable /// The elements that make up the selection set in the new object ///
context CQ /// A CQ object that will be assigned as the context for this one. ///
return System

CQ() public method

Create a new CQ object from an HTML stream. CQ.Create(char[])
public CQ ( System.Stream html, Encoding encoding, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default ) : System
html System.Stream /// The html source of the new document. ///
encoding System.Text.Encoding /// The character set encoding. ///
parsingMode HtmlParsingMode /// The HTML parsing mode. ///
parsingOptions HtmlParsingOptions /// (optional) options for controlling the parsing. ///
docType DocType /// (optional) type of the document. ///
return System

CQ() public method

Create a new CQ object from an HTML string.
public CQ ( System.Text.TextReader html, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default ) : System
html System.Text.TextReader /// The html source of the new document. ///
parsingMode HtmlParsingMode /// The HTML parsing mode. ///
parsingOptions HtmlParsingOptions /// (optional) options for controlling the parsing. ///
docType DocType /// (optional) type of the document. ///
return System

CQ() public method

Create a new CsQuery object using an existing instance and a selector. if the selector is null or missing, then it will contain no selection results.
public CQ ( string selector, CQ context ) : System
selector string /// A valid CSS selector. ///
context CQ /// The context. ///
return System

CQ() public method

Create a new CQ object from an HTML string.
public CQ ( string html, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default ) : System
html string /// The HTML source. ///
parsingMode HtmlParsingMode /// The HTML parsing mode. ///
parsingOptions HtmlParsingOptions /// (optional) options for controlling the parsing. ///
docType DocType /// (optional) type of the document. ///
return System

CQ() public method

Create a new CsQuery object from a selector or HTML, and assign CSS, within a context.
public CQ ( string selector, object css, CQ context ) : System
selector string /// The selector or HTML markup ///
css object /// The object whose property names and values map to CSS ///
context CQ /// The context ///
return System

CQ() public method

Create a new CsQuery object from a selector HTML, and assign CSS from a JSON string, within a context.
public CQ ( string selector, string cssJson, CQ context ) : System
selector string /// The ///
cssJson string /// The JSON containing CSS ///
context CQ /// The context ///
return System

Create() public static method

Create an empty CQ object.
public static Create ( ) : CQ
return CQ

Create() public static method

Create a new CQ object from a single element. Unlike the constructor method CsQuery.CQ this new objet is not bound to any context from the element.
public static Create ( IDomObject element ) : CQ
element IDomObject /// The element to wrap ///
return CQ

Create() public static method

Creeate a new CQ object from a squence of elements, or another CQ object. The new object will contain clones of the original objects; they are no longer bound to their owning context. If you want to wrap these elements and retain their context, use "new CQ(...)" instead.
public static Create ( IEnumerable elements ) : CQ
elements IEnumerable /// A sequence of elements. ///
return CQ

Create() public static method

Create a new CQ object from a stream of HTML text, attempting to automatically detect the character set encoding from BOM.
public static Create ( System.Stream html ) : CQ
html System.Stream /// An open Stream. ///
return CQ

Create() public static method

Create a new CQ from a stream of HTML text in the specified encoding.
public static Create ( System.Stream html, Encoding encoding ) : CQ
html System.Stream /// An open Stream. ///
encoding System.Text.Encoding /// The character set encoding. ///
return CQ

Create() public static method

Create a new CQ object from a stream of HTML, treating the HTML as a content document.
public static Create ( System.Stream html, Encoding encoding = null, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default ) : CQ
html System.Stream /// An open Stream. ///
encoding System.Text.Encoding /// The character set encoding. ///
parsingMode HtmlParsingMode /// (optional) the mode. ///
parsingOptions HtmlParsingOptions /// (optional) options for controlling the parsing. ///
docType DocType /// (optional) type of the document. ///
return CQ

Create() public static method

Create a new CQ object from a TextReader containing HTML.
public static Create ( System.Text.TextReader html ) : CQ
html System.Text.TextReader /// A TextReader containing HTML. ///
return CQ

Create() public static method

Create a new CQ object from a TextReader containg HTML
public static Create ( System.Text.TextReader html, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default ) : CQ
html System.Text.TextReader /// A string of HTML. ///
parsingMode HtmlParsingMode /// (optional) the mode. ///
parsingOptions HtmlParsingOptions /// (optional) options for controlling the parsing. ///
docType DocType /// (optional) type of the document. ///
return CQ

Create() public static method

Create a new CQ object from an HTML character array. Node: this method is obsolete; it may be removed in a future release. Character arrays were supported in prior versions because this was how all data was converted internally; this is not the case any more, and it's an unlikely format for typical input. Use string or stream methods instead.
public static Create ( char html ) : CQ
html char /// The HTML source for the document. ///
return CQ

Create() public static method

Create a new CQ object from a single element. Unlike the constructor method CsQuery.CQ this new objet is not bound to any context from the element.
public static Create ( string html ) : CQ
html string /// A string containing HTML. ///
return CQ

Create() public static method

Creeate a new CQ object from an HTML string.
public static Create ( string html, HtmlParsingMode parsingMode = HtmlParsingMode.Auto, HtmlParsingOptions parsingOptions = HtmlParsingOptions.Default, DocType docType = DocType.Default ) : CQ
html string /// A string containing HTML. ///
parsingMode HtmlParsingMode /// (optional) the mode. ///
parsingOptions HtmlParsingOptions /// (optional) options for controlling the parsing. ///
docType DocType /// (optional) type of the document. ///
return CQ

Create() public static method

Create a new CQ from an HTML fragment, and use quickSet to create attributes (and/or css)
public static Create ( string html, object quickSet ) : CQ
html string /// A string of HTML. ///
quickSet object /// an object containing CSS properties and attributes to be applied to the resulting fragment. ///
return CQ

CreateDocument() public static method

Creates a new DOM from a stream containing HTML
public static CreateDocument ( System.Stream html ) : CQ
html System.Stream /// An open Stream ///
return CQ

CreateDocument() public static method

Creeate a new DOM from HTML text using full HTML5 tag generation.
public static CreateDocument ( System.Stream html, Encoding encoding ) : CQ
html System.Stream /// An open Stream. ///
encoding System.Text.Encoding /// The character set encoding. ///
return CQ

CreateDocument() public static method

Creates a new DOM from a stream containing HTML
public static CreateDocument ( System.Text.TextReader html ) : CQ
html System.Text.TextReader /// A n open Stream ///
return CQ

CreateDocument() public static method

Creeate a new DOM from HTML text using full HTML5 tag generation.
public static CreateDocument ( string html ) : CQ
html string /// A string of HTML ///
return CQ

CreateDocumentFromFile() public static method

Creates a new DOM from an HTML file.
public static CreateDocumentFromFile ( string htmlFile ) : CQ
htmlFile string /// The full path to the file ///
return CQ

CreateFragment() public static method

Create a new CQ object from a sequence of elements, or another CQ object.
public static CreateFragment ( IEnumerable elements ) : CQ
elements IEnumerable /// A sequence of elements. ///
return CQ

CreateFragment() public static method

Create a new fragment from a TextReader containing HTML text.
public static CreateFragment ( string html ) : CQ
html string /// A string of HTML. ///
return CQ

CreateFragment() public static method

Creeate a new fragment from HTML text, in the context of a specific HTML tag.
public static CreateFragment ( string html, string context ) : CQ
html string /// A string of HTML. ///
context string /// The HTML tag name which is the context ///
return CQ

CreateFromFile() public static method

Creates a new DOM from an HTML file.
public static CreateFromFile ( string htmlFile ) : CQ
htmlFile string /// The full path to the file ///
return CQ

CreateNew() protected method

Bind this instance to a new DomFragment created from HTML in a specific HTML tag context.
protected CreateNew ( CQ target, System.Stream html, Encoding encoding, HtmlParsingMode parsingMode, HtmlParsingOptions parsingOptions, DocType docType ) : void
target CQ /// The target. ///
html System.Stream /// The HTML. ///
encoding System.Text.Encoding /// The character set encoding. ///
parsingMode HtmlParsingMode /// The HTML parsing mode. ///
parsingOptions HtmlParsingOptions /// (optional) options for controlling the parsing. ///
docType DocType /// (optional) type of the document. ///
return void

CreateNewDocument() protected method

Bind this instance to a new empty DomDocument configured with the default options.
protected CreateNewDocument ( ) : void
return void

CreateNewFragment() protected method

Bind this instance to a new empty DomFragment configured with the default options.
protected CreateNewFragment ( ) : void
return void

CreateNewFragment() protected method

Bind this instance to a new DomFragment created from HTML using the specified parsing mode and element context
protected CreateNewFragment ( CQ target, string html, string context, DocType docType ) : void
target CQ /// The target. ///
html string /// The HTML. ///
context string /// The context (e.g. an HTML tag name) ///
docType DocType /// (optional) type of the document. ///
return void

CreateNewFragment() protected method

Bind this instance to a new DomFragment created from a sequence of elements.
protected CreateNewFragment ( IEnumerable elements ) : void
elements IEnumerable /// The elements to provide the source for this object's DOM. ///
return void

InsertAtOffset() protected method

Insert every element in the selection at or after the index of each target (adding offset to the index). If there is more than one target, the a clone is made of the selection for the 2nd and later targets.
This is a helper for Before and After. There is special handling when the target is not part of a DOM. Instead of altering the DOM, this method will alter the selection set, and return a CQ object that contains the new sequence. Normally, it would return the same CQ object (but alter the DOM).
protected InsertAtOffset ( CQ target, int offset, CQ &insertedElements ) : CQ
target CQ /// The target element. ///
offset int /// The offset from the target at which to begin inserting. ///
insertedElements CQ /// [out] The inserted elements. ///
return CQ

InsertAtOffset() protected method

Inserts an element at the specified offset from a target. Helper method for Before and After.
protected InsertAtOffset ( IEnumerable target, int offset ) : CQ
target IEnumerable /// Target for the. ///
offset int /// The offset. ///
return CQ