API Reference
HtmlDocument
An owned HTML tree with explicit snapshot and mutation semantics. Mutable documents require a single owner.
Inheritance
- HtmlNode
- HtmlDocument
Usage
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by
- Method HtmlDocument.Clone
- Method HtmlDocument.Edit
- Method HtmlDocument.Freeze
- Property HtmlDocument.Document
- Property HtmlDocumentType.Document
- Property HtmlElement.Document
- Property HtmlNode.Document
- Method IHtmlParserProvider.Parse
Accepted by parameters
- Method HtmlDocument.Edit
Constructors
public HtmlDocument(IHtmlDomServices services, String providerId, HtmlDocumentMode mode = Standards) #Creates an empty mutable document for a parser or programmatic authoring.
Parameters
- services OfficeIMO.Html.Dom.IHtmlDomServices
- providerId System.String
- mode OfficeIMO.Html.Dom.HtmlDocumentMode = Standards
Methods
public HtmlDocument Clone() #HtmlDocumentCreates an independent mutable clone, preserving node IDs and source positions.
public HtmlNode CreateComment(String text) #HtmlNodeCreates a comment in this mutable document.
Parameters
- text System.String
public HtmlDocumentType CreateDocumentType(String name, String publicIdentifier = "", String systemIdentifier = "") #HtmlDocumentTypeCreates a document type with the supplied identifiers.
Parameters
- name System.String
- publicIdentifier System.String = ""
- systemIdentifier System.String = ""
public HtmlElement CreateElement(String localName, String namespaceUri = "http://www.w3.org/1999/xhtml", String prefix = null) #HtmlElementCreates a detached element in this mutable document.
Parameters
- localName System.String
- namespaceUri System.String = "http://www.w3.org/1999/xhtml"
- prefix System.String = null
public HtmlNode CreateFragment() #HtmlNodeCreates a detached fragment in this mutable document.
public HtmlNode CreateTextNode(String text) #HtmlNodeCreates decoded text in this mutable document.
Parameters
- text System.String
public HtmlDocument Edit(Action<HtmlDocument> edit) #HtmlDocumentApplies edits to an independent clone and freezes the returned snapshot.
Parameters
- edit System.Action{OfficeIMO.Html.Dom.HtmlDocument}
public HtmlDocument Freeze() #HtmlDocumentFreezes this instance. Every retained node handle becomes read-only.
public HtmlNode GetNode(Int32 nodeId) #HtmlNodeFinds a node by its document-local identity, including detached nodes.
Parameters
- nodeId System.Int32
public HtmlNode GetOrCreateTemplateContent(HtmlElement template) #HtmlNodeCreates or returns this template element's separate content fragment.
Parameters
- template OfficeIMO.Html.Dom.HtmlElement
public Void SetSourceIndex(HtmlNode node, Nullable<Int32> sourceIndex) #VoidAttaches an original UTF-16 source position while constructing a mutable tree.
Parameters
- node OfficeIMO.Html.Dom.HtmlNode
- sourceIndex System.Nullable{System.Int32}
Inherited Methods
public HtmlNode AppendChild(HtmlNode child) #HtmlNodeParameters
- child HtmlNode
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object
public HtmlElement QuerySelector(String selector) #HtmlElementParameters
- selector String
public IReadOnlyList<HtmlElement> QuerySelectorAll(String selector) #IReadOnlyList<HtmlElement>Parameters
- selector String
Properties
public Guid SnapshotId { get; } #Unique identity of this tree instance; clones have independent identities.
public Int64 Revision { get; set; } #Mutation revision used to invalidate derived state.
public Boolean IsReadOnly { get; set; } #Whether this tree rejects further mutation, including detached nodes.
public String ProviderId { get; } #Parser identity attached when the tree was created.
public HtmlDocumentMode Mode { get; } #Layout compatibility mode established by the parser.
public IHtmlDomServices Services { get; } #Syntax services used for queries and serialization.
public HtmlElement DocumentElement { get; } #Root element, if present.
public HtmlElement Body { get; } #Direct HTML body or frameset child of the root.
public HtmlElement Head { get; } #Direct HTML head child of the root.