Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
HtmlNode.cs
2using System.Text;
3using System.Xml;
4
5namespace Waher.Content.Html
6{
10 public abstract class HtmlNode
11 {
12 private readonly HtmlDocument document;
13 private readonly HtmlNode parent;
14 private int start;
15 private int end;
16
24 {
25 this.document = Document;
26 this.parent = Parent;
27 this.start = StartPosition;
28 this.end = -1;
29 }
30
39 {
40 this.document = Document;
41 this.parent = Parent;
42 this.start = StartPosition;
43 this.end = EndPosition;
44 }
45
49 public HtmlDocument Document => this.document;
50
54 public HtmlNode Parent => this.parent;
55
59 public int StartPosition
60 {
61 get => this.start;
62 internal set => this.start = value;
63 }
64
68 public int EndPosition
69 {
70 get => this.end;
71 internal set => this.end = value;
72 }
73
77 public string OuterHtml
78 {
79 get
80 {
81 return this.document.HtmlText.Substring(this.start, this.end - this.start + 1);
82 }
83 }
84
92 protected static void SplitName(string FullName, out string Prefix, out string LocalName,
93 out bool HasPrefix)
94 {
95 int i = FullName.IndexOf(':');
96 if (i < 0)
97 {
98 LocalName = FullName;
99 Prefix = null;
100 HasPrefix = false;
101 }
102 else
103 {
104 Prefix = FullName.Substring(0, i);
105 LocalName = FullName.Substring(i + 1);
106 HasPrefix = true;
107 }
108 }
109
115 public abstract void Export(XmlWriter Output, Dictionary<string, string> Namespaces);
116
121 public abstract void Export(StringBuilder Output);
122 }
123}
Base class for all HTML nodes.
Definition: HtmlNode.cs:11
HtmlNode(HtmlDocument Document, HtmlNode Parent, int StartPosition, int EndPosition)
Base class for all HTML nodes.
Definition: HtmlNode.cs:38
HtmlNode(HtmlDocument Document, HtmlNode Parent, int StartPosition)
Base class for all HTML nodes.
Definition: HtmlNode.cs:23
int StartPosition
Start position of element.
Definition: HtmlNode.cs:60
static void SplitName(string FullName, out string Prefix, out string LocalName, out bool HasPrefix)
Splits a full name into a prefix (if available) and a local name.
Definition: HtmlNode.cs:92
HtmlDocument Document
HTML Document
Definition: HtmlNode.cs:49
HtmlNode Parent
Parent node, if available.
Definition: HtmlNode.cs:54
int EndPosition
End position of element.
Definition: HtmlNode.cs:69
abstract void Export(XmlWriter Output, Dictionary< string, string > Namespaces)
Exports the HTML document to XML.
string OuterHtml
Outer HTML
Definition: HtmlNode.cs:78
abstract void Export(StringBuilder Output)
Exports the HTML document to XML.