HtmlQuery Class

Summary

Queries HTML content of the input documents and creates new documents with content and metadata from the results.
Assembly
Wyam.Html.dll
Namespace
Wyam.Html
Interfaces
Base Types
  • Object
graph BT Type-->Base0["Object"] Type-.->Interface0["IModule"] click Interface0 "/api/Wyam.Common.Modules/IModule" Type["HtmlQuery"] class Type type-node

Syntax

public class HtmlQuery : IModule

Remarks

Once you provide a DOM query selector, the module creates new output documents for each query result and allows you to set the new document content and/or set new metadata based on the query result.

Note that because this module parses the document content as standards-compliant HTML and outputs the formatted post-parsed DOM, you should only place this module after all other template processing has been performed.

Constructors

Name Summary
HtmlQuery(string) Creates the module with the specified query selector.

Methods

Name Value Summary
Execute(IReadOnlyList<IDocument>, IExecutionContext) IEnumerable<IDocument>
This should not be called directly, instead call IExecutionContext.Execute() if you need to execute a module from within another module.
First(bool) HtmlQuery
Specifies that only the first query result should be processed (the default is false).
GetAll() HtmlQuery
Gets all information for each query result and sets the metadata of the corresponding result document(s). This is equivalent to calling GetOuterHtml(), GetInnerHtml(), GetTextContent(), and GetAttributeValues() with default arguments.
GetAttributeValue(string, string) HtmlQuery
Gets the specified attribute value of each query result and sets it in the metadata of the corresponding result document(s). If the attribute is not found for a given query result, no metadata is set. If metadataKey is null, the attribute name will be used as the metadata key, otherwise the specified metadata key will be used.
GetAttributeValues() HtmlQuery
Gets the values for all attributes of each query result and sets them in the metadata of the corresponding result document(s) with keys names equal to the attribute local name.
GetInnerHtml(string) HtmlQuery
Gets the inner HTML of each query result and sets it in the metadata of the corresponding result document(s) with the specified key.
GetOuterHtml(string) HtmlQuery
Gets the outer HTML of each query result and sets it in the metadata of the corresponding result document(s) with the specified key.
GetTextContent(string) HtmlQuery
Gets the text content of each query result and sets it in the metadata of the corresponding result document(s) with the specified key.
SetContent(Nullable<bool>) HtmlQuery
Sets the content of the result document(s) to the content of the corresponding query result, optionally specifying whether inner or outer HTML content should be used. The default is null, which does not add any content to the result documents (only metadata).
GitHub