/// <summary> /// Initializes a new instance of the <see cref="HtmlAttribute"/> class. /// </summary> /// <param name="ownerdocument">The owner document.</param> internal HtmlAttribute(HtmlDocument ownerdocument) { this.QuoteType = AttributeValueQuote.DoubleQuote; this.OwnerDocument = ownerdocument; }
/// <summary> /// Creates an HTML node from a string representing literal HTML. /// </summary> /// <param name="html"> /// The HTML text. /// </param> /// <returns> /// The newly created node instance. /// </returns> public static HtmlNode CreateNode(string html) { // REVIEW: this is *not* optimum... var doc = new HtmlDocument(); doc.LoadHtml(html); return doc.DocumentNode.FirstChild; }
/// <summary> /// Initializes a new instance of the <see cref="HtmlNodeNavigator"/> class. /// </summary> /// <param name="nav"> /// The nav. /// </param> private HtmlNodeNavigator(HtmlNodeNavigator nav) { if (nav == null) { throw new ArgumentNullException("nav"); } this.htmlDocument = nav.htmlDocument; this.currentnode = nav.currentnode; this.attindex = nav.attindex; this.htmlNameTable = nav.htmlNameTable; // REVIEW: should we do this? }
/// <summary> /// Initializes a new instance of the <see cref="HtmlNode"/> class. /// Initializes HtmlNode, providing type, owner and where it exists in a collection /// </summary> /// <param name="type">The type.</param> /// <param name="ownerdocument">The owner document.</param> /// <param name="index">The index.</param> public HtmlNode(HtmlNodeType type, HtmlDocument ownerdocument, int index) { this.NodeType = type; this.OwnerDocument = ownerdocument; this.OuterStartIndex = index; switch (type) { case HtmlNodeType.Comment: this.NodeName = HtmlNodeTypeNameComment; this.EndNode = this; break; case HtmlNodeType.Document: this.NodeName = HtmlNodeTypeNameDocument; this.EndNode = this; break; case HtmlNodeType.Text: this.NodeName = HtmlNodeTypeNameText; this.EndNode = this; break; } if (this.OwnerDocument.Openednodes != null) { if (!this.Closed) { // we use the index as the key // -1 means the node comes from public if (-1 != index) { this.OwnerDocument.Openednodes.Add(index, this); } } } if ((-1 != index) || (type == HtmlNodeType.Comment) || (type == HtmlNodeType.Text)) { return; } // innerhtml and outerhtml must be calculated this.OuterChanged = true; this.InnerChanged = true; }
/// <summary> /// Initializes a new instance of the <see cref="HtmlNodeNavigator"/> class. /// </summary> /// <param name="doc">The doc.</param> /// <param name="currentNode">The current node.</param> internal HtmlNodeNavigator(HtmlDocument doc, HtmlNode currentNode) { if (currentNode == null) { throw new ArgumentNullException("currentNode"); } if (currentNode.OwnerDocument != doc) { throw new ArgumentException(HtmlDocument.HtmlExceptionRefNotChild); } this.htmlDocument = doc; this.Reset(); this.currentnode = currentNode; }