2using System.Collections.Generic;
3using System.Globalization;
15 private readonly
string htmlText;
18 private Title title =
null;
19 private Body body =
null;
20 private Head head =
null;
21 private LinkedList<Main> main =
null;
22 private LinkedList<Header> header =
null;
23 private LinkedList<Footer> footer =
null;
24 private LinkedList<Details> details =
null;
25 private LinkedList<Summary> summary =
null;
26 private LinkedList<Article> article =
null;
27 private LinkedList<DtdInstruction> dtd =
null;
28 private LinkedList<ProcessingInstruction> processingInstructions =
null;
29 private LinkedList<Link> link =
null;
30 private LinkedList<Meta> meta =
null;
31 private LinkedList<Style> style =
null;
32 private LinkedList<Address> address =
null;
33 private LinkedList<Aside> aside =
null;
34 private LinkedList<Nav> nav =
null;
35 private LinkedList<Section> section =
null;
36 private LinkedList<Dialog> dialog =
null;
37 private LinkedList<Figure> figure =
null;
38 private LinkedList<Elements.Audio> audio =
null;
39 private LinkedList<Elements.Video> video =
null;
40 private LinkedList<Img> img =
null;
41 private LinkedList<Picture> picture =
null;
42 private LinkedList<Cite> cite =
null;
43 private LinkedList<Data> data =
null;
44 private LinkedList<Time> time =
null;
45 private LinkedList<Elements.Script> script =
null;
46 private LinkedList<Form> form =
null;
62 private void AssertParsed()
64 if (this.root is
null)
263 public IEnumerable<Nav>
Nav
311 public IEnumerable<Elements.Audio>
Audio
323 public IEnumerable<Elements.Video>
Video
335 public IEnumerable<Img>
Img
395 public IEnumerable<Elements.Script>
Script
419 public IEnumerable<DtdInstruction>
Dtd
436 return this.processingInstructions;
442 StringBuilder sb =
new StringBuilder();
446 string Name =
string.Empty;
449 char EndChar =
'\x00';
452 int StartOfElement = 0;
454 int StartOfAttribute = 0;
455 int Len = this.htmlText.Length;
457 bool CurrentElementIsScript =
false;
459 for (Pos = 0; Pos < Len; Pos++)
461 ch = this.htmlText[Pos];
471 CurrentElement = CurrentElement.Parent as
HtmlElement;
473 CurrentElement?.Add(
new HtmlText(
this, CurrentElement, StartOfText, Pos - 1, sb.ToString()));
479 StartOfElement = Pos;
487 CurrentElement = CurrentElement.Parent as
HtmlElement;
489 CurrentElement?.Add(
new HtmlText(
this, CurrentElement, StartOfText, Pos - 1, sb.ToString()));
509 else if (CurrentElementIsScript)
513 StartOfText = Pos + 1 - sb.Length;
519 else if (ch ==
'!' && Empty)
521 else if (CurrentElementIsScript)
525 StartOfText = Pos + 1 - sb.Length;
534 StartOfText = Pos + 1 - sb.Length;
539 CurrentElement = this.CreateElement(CurrentElement, sb.ToString(), StartOfElement, Pos);
540 CurrentElementIsScript = CurrentElement is Elements.Script;
545 StartOfText = Pos + 1;
549 else if (ch <=
' ' || ch == 160)
556 StartOfText = Pos + 1 - sb.Length;
559 else if (CurrentElementIsScript)
563 StartOfText = Pos + 1 - sb.Length;
568 CurrentElement = this.CreateElement(CurrentElement, sb.ToString(), StartOfElement, Pos);
569 CurrentElementIsScript = CurrentElement is Elements.Script;
579 else if (IsNameCharacter(ch))
589 StartOfText = Pos + 1 - sb.Length;
597 else if (CurrentElementIsScript)
602 StartOfText = Pos + 1 - sb.Length;
607 if (this.dtd is
null)
608 this.dtd =
new LinkedList<DtdInstruction>();
613 CurrentElement = CurrentElement.Parent as
HtmlElement;
615 CurrentElement?.Add(
Dtd);
616 this.dtd.AddLast(
Dtd);
618 StartOfText = Pos + 1;
635 EmptyElement = this.CreateElement(CurrentElement, sb.ToString(), StartOfElement, Pos);
636 EmptyElement.EndPosition = Pos;
641 StartOfText = Pos + 1;
656 s = sb.ToString().ToUpper();
660 if (!(CurrentElement is
null))
663 CurrentElement.EndPosition = Pos;
665 if (CurrentElement.
Name == s)
667 CurrentElement = CurrentElement.Parent as
HtmlElement;
668 CurrentElementIsScript = CurrentElement is Elements.Script;
674 while (!(Loop is
null) && Loop.
Name != s)
681 while (!(Loop is
null) && Loop.
Name != s)
684 Loop.EndPosition = Pos;
690 Loop.EndPosition = Pos;
693 CurrentElementIsScript = CurrentElement is Elements.Script;
698 StartOfText = Pos + 1;
712 CurrentElement.EndPosition = Pos;
714 StartOfText = Pos + 1;
721 StartOfAttribute = Pos;
725 else if (ch >
' ' && ch != 160)
727 if (IsNameCharacter(ch))
729 StartOfAttribute = Pos;
747 CurrentElement.AddAttribute(
new HtmlAttribute(
this, CurrentElement, StartOfAttribute, Pos - 1, sb.ToString(),
string.Empty));
752 StartOfText = Pos + 1;
757 CurrentElement.AddAttribute(
new HtmlAttribute(
this, CurrentElement, StartOfAttribute, Pos - 1, sb.ToString(),
string.Empty));
766 Name = sb.ToString();
775 if (ch <=
' ' || ch == 160)
777 CurrentElement.AddAttribute(
new HtmlAttribute(
this, CurrentElement, StartOfAttribute, Pos - 1, sb.ToString(),
string.Empty));
784 else if (IsNameCharacter(ch))
800 if (ch ==
'"' || ch ==
'\'')
802 CurrentAttribute =
new HtmlAttribute(
this, CurrentElement, StartOfAttribute, Name);
803 CurrentElement.AddAttribute(CurrentAttribute);
810 CurrentElement.AddAttribute(
new HtmlAttribute(
this, CurrentElement, StartOfAttribute, Pos - 1, Name, Name));
811 StartOfText = Pos + 1;
816 CurrentElement.AddAttribute(
new HtmlAttribute(
this, CurrentElement, StartOfAttribute, Pos - 1, Name, Name));
819 else if (ch >
' ' && ch != 160)
827 CurrentElement.AddAttribute(
new HtmlAttribute(
this, CurrentElement, StartOfAttribute, Pos - 1, Name, Name));
837 if (ch <=
' ' || ch == 160)
839 CurrentElement.AddAttribute(
new HtmlAttribute(
this, CurrentElement, StartOfAttribute, Pos - 1, Name, sb.ToString()));
848 CurrentElement.AddAttribute(
new HtmlAttribute(
this, CurrentElement, StartOfAttribute, Pos - 1, Name, sb.ToString()));
853 StartOfText = Pos + 1;
858 CurrentElement.AddAttribute(
new HtmlAttribute(
this, CurrentElement, StartOfAttribute, Pos - 1, Name, sb.ToString()));
875 CurrentElement.EndPosition = Pos;
876 CurrentElement = CurrentElement.Parent as
HtmlElement;
877 CurrentElementIsScript = CurrentElement is Elements.Script;
878 StartOfText = Pos + 1;
884 if ((ch >=
'a' && ch <=
'z') || (ch >=
'A' && ch <=
'Z') || (ch >=
'0' && ch <=
'9'))
897 StartOfText = Pos + 1 - sb.Length;
909 if (CurrentAttribute.HasSegments)
910 CurrentAttribute.Add(
new HtmlText(
this, CurrentAttribute, Pos - s.Length, Pos - 1, s));
912 CurrentAttribute.Value = s;
914 CurrentAttribute.EndPosition = Pos;
928 CurrentAttribute.Add(
new HtmlText(
this, CurrentAttribute, Pos - s.Length, Pos - 1, s));
944 if ((ch >=
'a' && ch <=
'z') || (ch >=
'A' && ch <=
'Z') || (ch >=
'0' && ch <=
'9'))
964 StartOfText = Pos + 1;
974 if (this.dtd is
null)
975 this.dtd =
new LinkedList<DtdInstruction>();
981 CurrentElement = CurrentElement.Parent as
HtmlElement;
983 CurrentElement?.Add(
Dtd);
984 this.dtd.AddLast(
Dtd);
989 StartOfText = Pos + 1;
1008 StartOfText = Pos + 1 - sb.Length;
1040 CurrentElement = CurrentElement.Parent as
HtmlElement;
1043 CurrentElement?.Add(
new Comment(
this, CurrentElement, Pos - s.Length - 5, Pos, s));
1048 StartOfText = Pos + 1;
1079 if (this.processingInstructions is
null)
1080 this.processingInstructions =
new LinkedList<ProcessingInstruction>();
1086 CurrentElement = CurrentElement.Parent as
HtmlElement;
1088 CurrentElement?.Add(PI);
1089 this.processingInstructions.AddLast(PI);
1094 StartOfText = Pos + 1;
1115 StartOfText = Pos + 1 - sb.Length;
1128 StartOfText = Pos + 1 - sb.Length;
1141 StartOfText = Pos + 1 - sb.Length;
1151 sb.Append(
"<![CDA");
1154 StartOfText = Pos + 1 - sb.Length;
1164 sb.Append(
"<![CDAT");
1167 StartOfText = Pos + 1 - sb.Length;
1177 sb.Append(
"<![CDATA");
1180 StartOfText = Pos + 1 - sb.Length;
1211 CurrentElement = CurrentElement.Parent as
HtmlElement;
1214 CurrentElement?.Add(
new CDATA(
this, CurrentElement, Pos - s.Length - 10, Pos, s));
1219 StartOfText = Pos + 1;
1232 if ((ch >=
'a' && ch <=
'z') || (ch >=
'A' && ch <=
'Z') || (ch >=
'0' && ch <=
'9'))
1237 CurrentElement = CurrentElement.Parent as
HtmlElement;
1240 CurrentElement?.Add(
new HtmlEntity(
this, CurrentElement, Pos - s.Length - 1, Pos, s));
1245 StartOfText = Pos + 1;
1253 StartOfText = Pos + 1 - sb.Length;
1259 if (ch >=
'0' && ch <=
'9')
1264 else if (ch ==
'x' || ch ==
'X')
1266 else if (ch ==
';' &&
int.TryParse(s = sb.ToString(), out
int Code))
1269 CurrentElement = CurrentElement.Parent as
HtmlElement;
1271 CurrentElement?.Add(
new HtmlEntityUnicode(
this, CurrentElement, Pos - s.Length - 1, Pos,
"#" + s,
Code));
1276 StartOfText = Pos + 1;
1284 StartOfText = Pos + 1 - sb.Length;
1290 if (ch >=
'0' && ch <=
'9')
1292 else if (ch ==
';' &&
int.TryParse(s = sb.ToString(), out
int Code))
1295 CurrentElement = CurrentElement.Parent as
HtmlElement;
1297 CurrentElement?.Add(
new HtmlEntityUnicode(
this, CurrentElement, Pos - s.Length - 1, Pos,
"#" + s,
Code));
1302 StartOfText = Pos + 1;
1310 StartOfText = Pos + 1 - sb.Length;
1316 if ((ch >=
'0' && ch <=
'9') || (ch >=
'a' && ch <=
'f') || (ch >=
'A' && ch <=
'F'))
1318 else if (ch ==
';' &&
int.TryParse(s = sb.ToString(), NumberStyles.HexNumber,
null, out
int Code))
1321 CurrentElement = CurrentElement.Parent as
HtmlElement;
1323 CurrentElement?.Add(
new HtmlEntityUnicode(
this, CurrentElement, Pos - s.Length - 1, Pos,
"#x" + s,
Code));
1328 StartOfText = Pos + 1;
1333 sb.Insert(0,
"&#x");
1336 StartOfText = Pos + 1 - sb.Length;
1342 if ((ch >=
'a' && ch <=
'z') || (ch >=
'A' && ch <=
'Z') || (ch >=
'0' && ch <=
'9'))
1347 CurrentAttribute.Add(
new HtmlEntity(
this, CurrentAttribute, Pos - s.Length - 1, Pos, s));
1352 StartOfText = Pos + 1;
1360 StartOfText = Pos + 1 - sb.Length;
1366 if (ch >=
'0' && ch <=
'9')
1371 else if (ch ==
'x' || ch ==
'X')
1373 else if (ch ==
';' &&
int.TryParse(s = sb.ToString(), out
int Code))
1375 CurrentAttribute.Add(
new HtmlEntityUnicode(
this, CurrentAttribute, Pos - s.Length - 1, Pos, s,
Code));
1380 StartOfText = Pos + 1;
1388 StartOfText = Pos + 1 - sb.Length;
1394 if (ch >=
'0' && ch <=
'9')
1396 else if (ch ==
';' &&
int.TryParse(s = sb.ToString(), out
int Code))
1398 CurrentAttribute.Add(
new HtmlEntityUnicode(
this, CurrentAttribute, Pos - s.Length - 1, Pos, s,
Code));
1403 StartOfText = Pos + 1;
1411 StartOfText = Pos + 1 - sb.Length;
1417 if ((ch >=
'0' && ch <=
'9') || (ch >=
'a' && ch <=
'f') || (ch >=
'A' && ch <=
'F'))
1419 else if (ch ==
';' &&
int.TryParse(s = sb.ToString(), NumberStyles.HexNumber,
null, out
int Code))
1421 CurrentAttribute.Add(
new HtmlEntityUnicode(
this, CurrentAttribute, Pos - s.Length - 1, Pos, s,
Code));
1426 StartOfText = Pos + 1;
1431 sb.Insert(0,
"&#x");
1434 StartOfText = Pos + 1 - sb.Length;
1440 throw new Exception(
"Internal error: Unrecognized state.");
1452 CurrentElement = CurrentElement.Parent as
HtmlElement;
1455 CurrentElement?.Add(
new HtmlText(
this, CurrentElement, Pos - s.Length, Pos - 1, s));
1460 CurrentElement.AddAttribute(
new HtmlAttribute(
this, CurrentElement, StartOfAttribute, Pos - 1, s, s));
1464 CurrentElement.AddAttribute(
new HtmlAttribute(
this, CurrentElement, StartOfAttribute, Pos - 1, Name, Name));
1468 CurrentElement.AddAttribute(
new HtmlAttribute(
this, CurrentElement, StartOfAttribute, Pos - 1, Name, sb.ToString()));
1474 CurrentElement = CurrentElement.Parent as
HtmlElement;
1478 CurrentElement?.Add(
new HtmlText(
this, CurrentElement, Pos - s.Length, Pos - 1, s));
1484 if (CurrentAttribute.HasSegments)
1485 CurrentAttribute.Add(
new HtmlText(
this, CurrentAttribute, Pos - s.Length, Pos - 1, s));
1487 CurrentAttribute.Value = s;
1489 CurrentAttribute.EndPosition = Pos - 1;
1496 CurrentAttribute.Add(
new HtmlText(
this, CurrentElement, Pos - s.Length, Pos - 1, s));
1503 CurrentElement = CurrentElement.Parent as
HtmlElement;
1506 CurrentElement?.Add(
new Comment(
this, CurrentElement, Pos - s.Length - 5, Pos, s));
1511 if (this.processingInstructions is
null)
1512 this.processingInstructions =
new LinkedList<ProcessingInstruction>();
1518 CurrentElement = CurrentElement.Parent as
HtmlElement;
1520 CurrentElement?.Add(PI);
1521 this.processingInstructions.AddLast(PI);
1528 CurrentElement = CurrentElement.Parent as
HtmlElement;
1531 CurrentElement?.Add(
new CDATA(
this, CurrentElement, Pos - s.Length, Pos - 1, s));
1537 CurrentElement = CurrentElement.Parent as
HtmlElement;
1541 CurrentElement?.Add(
new HtmlText(
this, CurrentElement, Pos - s.Length, Pos - 1, s));
1546 CurrentElement = CurrentElement.Parent as
HtmlElement;
1548 sb.Insert(0,
"&#x");
1550 CurrentElement?.Add(
new HtmlText(
this, CurrentElement, Pos - s.Length, Pos - 1, s));
1558 CurrentAttribute.Add(
new HtmlText(
this, CurrentElement, Pos - s.Length, Pos - 1, s));
1562 sb.Insert(0,
"&#x");
1564 CurrentAttribute.Add(
new HtmlText(
this, CurrentElement, Pos - s.Length, Pos - 1, s));
1570 while (!(CurrentElement is
null))
1573 CurrentElement.EndPosition = Pos - 1;
1575 CurrentElement = CurrentElement.Parent as
HtmlElement;
1579 private static bool IsNameCharacter(
char ch)
1581 if (ch ==
'-' || ch ==
'.')
1614 if (ch ==
'\xd7' || ch ==
'\xf7')
1623 if (ch ==
'\x200c' || ch ==
'\x200d' || ch ==
'\x203f' || ch ==
'\x2040')
1666 TagName = TagName.ToUpper();
1670 case "A": Result =
new A(
this, Parent, Start);
break;
1671 case "ABBR": Result =
new Abbr(
this, Parent, Start);
break;
1672 case "ACRONYM": Result =
new Acronym(
this, Parent, Start);
break;
1676 if (this.address is
null)
1677 this.address =
new LinkedList<Address>();
1678 this.address.AddLast(
Address);
1681 case "APPLET": Result =
new Applet(
this, Parent, Start);
break;
1682 case "AREA": Result =
new Area(
this, Parent, Start);
break;
1686 if (this.article is
null)
1687 this.article =
new LinkedList<Article>();
1688 this.article.AddLast(
Article);
1694 if (this.aside is
null)
1695 this.aside =
new LinkedList<Aside>();
1696 this.aside.AddLast(
Aside);
1702 if (this.audio is
null)
1703 this.audio =
new LinkedList<Elements.Audio>();
1704 this.audio.AddLast(
Audio);
1707 case "B": Result =
new B(
this, Parent, Start);
break;
1708 case "BASE": Result =
new Base(
this, Parent, Start);
break;
1709 case "BASEFONT": Result =
new BaseFont(
this, Parent, Start);
break;
1710 case "BDI": Result =
new Bdi(
this, Parent, Start);
break;
1711 case "BDO": Result =
new Bdo(
this, Parent, Start);
break;
1712 case "BGSOUND": Result =
new BgSound(
this, Parent, Start);
break;
1713 case "BIG": Result =
new Big(
this, Parent, Start);
break;
1714 case "BLINK": Result =
new BLink(
this, Parent, Start);
break;
1715 case "BLOCKQUOTE": Result =
new BlockQuote(
this, Parent, Start);
break;
1719 if (this.body is
null)
1723 case "BR": Result =
new Br(
this, Parent, Start);
break;
1724 case "BUTTON": Result =
new Button(
this, Parent, Start);
break;
1725 case "CANVAS": Result =
new Canvas(
this, Parent, Start);
break;
1726 case "CAPTION": Result =
new Caption(
this, Parent, Start);
break;
1727 case "CENTER": Result =
new Center(
this, Parent, Start);
break;
1731 if (this.cite is
null)
1732 this.cite =
new LinkedList<Cite>();
1733 this.cite.AddLast(
Cite);
1736 case "CODE": Result =
new Code(
this, Parent, Start);
break;
1737 case "COL": Result =
new Col(
this, Parent, Start);
break;
1738 case "COLGROUP": Result =
new ColGroup(
this, Parent, Start);
break;
1739 case "COMMAND": Result =
new Command(
this, Parent, Start);
break;
1740 case "CONTENT": Result =
new Elements.Content(
this, Parent, Start);
break;
1744 if (this.data is
null)
1745 this.data =
new LinkedList<Data>();
1746 this.data.AddLast(
Data);
1749 case "DATALIST": Result =
new DataList(
this, Parent, Start);
break;
1750 case "DD": Result =
new Dd(
this, Parent, Start);
break;
1751 case "DEL": Result =
new Del(
this, Parent, Start);
break;
1755 if (this.details is
null)
1756 this.details =
new LinkedList<Details>();
1757 this.details.AddLast(
Details);
1760 case "DFN": Result =
new Dfn(
this, Parent, Start);
break;
1764 if (this.dialog is
null)
1765 this.dialog =
new LinkedList<Dialog>();
1766 this.dialog.AddLast(
Dialog);
1769 case "DIR": Result =
new Dir(
this, Parent, Start);
break;
1770 case "DIV": Result =
new Div(
this, Parent, Start);
break;
1771 case "DL": Result =
new Dl(
this, Parent, Start);
break;
1772 case "DT": Result =
new Dt(
this, Parent, Start);
break;
1773 case "ELEMENT": Result =
new Element(
this, Parent, Start);
break;
1774 case "EM": Result =
new Em(
this, Parent, Start);
break;
1775 case "EMBED": Result =
new Embed(
this, Parent, Start);
break;
1776 case "FIELDSET": Result =
new FieldSet(
this, Parent, Start);
break;
1777 case "FIGCAPTION": Result =
new FigCaption(
this, Parent, Start);
break;
1781 if (this.figure is
null)
1782 this.figure =
new LinkedList<Figure>();
1783 this.figure.AddLast(
Figure);
1786 case "FONT": Result =
new Font(
this, Parent, Start);
break;
1790 if (this.footer is
null)
1791 this.footer =
new LinkedList<Footer>();
1792 this.footer.AddLast(
Footer);
1798 if (this.form is
null)
1799 this.form =
new LinkedList<Form>();
1800 this.form.AddLast(
Form);
1803 case "FRAME": Result =
new Frame(
this, Parent, Start);
break;
1804 case "FRAMESET": Result =
new FrameSet(
this, Parent, Start);
break;
1805 case "H1": Result =
new Hn(
this, Parent, Start, 1);
break;
1806 case "H2": Result =
new Hn(
this, Parent, Start, 2);
break;
1807 case "H3": Result =
new Hn(
this, Parent, Start, 3);
break;
1808 case "H4": Result =
new Hn(
this, Parent, Start, 4);
break;
1809 case "H5": Result =
new Hn(
this, Parent, Start, 5);
break;
1810 case "H6": Result =
new Hn(
this, Parent, Start, 6);
break;
1811 case "H7": Result =
new Hn(
this, Parent, Start, 7);
break;
1812 case "H8": Result =
new Hn(
this, Parent, Start, 8);
break;
1813 case "H9": Result =
new Hn(
this, Parent, Start, 9);
break;
1817 if (this.head is
null)
1824 if (this.header is
null)
1825 this.header =
new LinkedList<Header>();
1826 this.header.AddLast(
Header);
1829 case "HGROUP": Result =
new HGroup(
this, Parent, Start);
break;
1830 case "HR": Result =
new Hr(
this, Parent, Start);
break;
1834 if (this.html is
null)
1838 case "I": Result =
new I(
this, Parent, Start);
break;
1839 case "IFRAME": Result =
new IFrame(
this, Parent, Start);
break;
1840 case "IMAGE": Result =
new Image(
this, Parent, Start);
break;
1844 if (this.img is
null)
1845 this.img =
new LinkedList<Img>();
1846 this.img.AddLast(
Img);
1849 case "INPUT": Result =
new Input(
this, Parent, Start);
break;
1850 case "INS": Result =
new Ins(
this, Parent, Start);
break;
1851 case "ISINDEX": Result =
new IsIndex(
this, Parent, Start);
break;
1852 case "KBD": Result =
new Kbd(
this, Parent, Start);
break;
1853 case "KEYGEN": Result =
new Keygen(
this, Parent, Start);
break;
1854 case "LABEL": Result =
new Label(
this, Parent, Start);
break;
1855 case "LEGEND": Result =
new Legend(
this, Parent, Start);
break;
1856 case "LI": Result =
new Li(
this, Parent, Start);
break;
1860 if (this.link is
null)
1861 this.link =
new LinkedList<Link>();
1862 this.link.AddLast(
Link);
1865 case "LISTING": Result =
new Listing(
this, Parent, Start);
break;
1869 if (this.main is
null)
1870 this.main =
new LinkedList<Main>();
1871 this.main.AddLast(
Main);
1874 case "MAP": Result =
new Map(
this, Parent, Start);
break;
1875 case "MARK": Result =
new Mark(
this, Parent, Start);
break;
1876 case "MARQUEE": Result =
new Marquee(
this, Parent, Start);
break;
1877 case "MENU": Result =
new Menu(
this, Parent, Start);
break;
1878 case "MENUITEM": Result =
new MenuItem(
this, Parent, Start);
break;
1882 if (this.meta is
null)
1883 this.meta =
new LinkedList<Meta>();
1884 this.meta.AddLast(
Meta);
1887 case "METER": Result =
new Meter(
this, Parent, Start);
break;
1888 case "MULTICOL": Result =
new MultiCol(
this, Parent, Start);
break;
1892 if (this.nav is
null)
1893 this.nav =
new LinkedList<Nav>();
1894 this.nav.AddLast(
Nav);
1897 case "NEXTID": Result =
new NextId(
this, Parent, Start);
break;
1898 case "NOBR": Result =
new NoBr(
this, Parent, Start);
break;
1899 case "NOEMBED": Result =
new NoEmbed(
this, Parent, Start);
break;
1900 case "NOFRAMES": Result =
new NoFrames(
this, Parent, Start);
break;
1901 case "NOSCRIPT": Result =
new NoScript(
this, Parent, Start);
break;
1902 case "OBJECT": Result =
new Elements.Object(
this, Parent, Start);
break;
1903 case "OL": Result =
new Ol(
this, Parent, Start);
break;
1904 case "OPTGROUP": Result =
new OptGroup(
this, Parent, Start);
break;
1905 case "OPTION": Result =
new Option(
this, Parent, Start);
break;
1906 case "OUTPUT": Result =
new Output(
this, Parent, Start);
break;
1907 case "P": Result =
new P(
this, Parent, Start);
break;
1908 case "PARAM": Result =
new Param(
this, Parent, Start);
break;
1912 if (this.picture is
null)
1913 this.picture =
new LinkedList<Picture>();
1914 this.picture.AddLast(
Picture);
1917 case "PLAINTEXT": Result =
new PlainText(
this, Parent, Start);
break;
1918 case "PRE": Result =
new Pre(
this, Parent, Start);
break;
1919 case "PROGRESS": Result =
new Progress(
this, Parent, Start);
break;
1920 case "Q": Result =
new Q(
this, Parent, Start);
break;
1921 case "RP": Result =
new Rp(
this, Parent, Start);
break;
1922 case "RT": Result =
new Rt(
this, Parent, Start);
break;
1923 case "RTC": Result =
new Rtc(
this, Parent, Start);
break;
1924 case "RUBY": Result =
new Ruby(
this, Parent, Start);
break;
1925 case "S": Result =
new S(
this, Parent, Start);
break;
1926 case "SAMP": Result =
new Samp(
this, Parent, Start);
break;
1930 if (this.script is
null)
1931 this.script =
new LinkedList<Elements.Script>();
1932 this.script.AddLast(
Script);
1938 if (this.section is
null)
1939 this.section =
new LinkedList<Section>();
1940 this.section.AddLast(
Section);
1943 case "SELECT": Result =
new Select(
this, Parent, Start);
break;
1944 case "SHADOW": Result =
new Shadow(
this, Parent, Start);
break;
1945 case "SLOT": Result =
new Slot(
this, Parent, Start);
break;
1946 case "SMALL": Result =
new Small(
this, Parent, Start);
break;
1947 case "SOURCE": Result =
new Source(
this, Parent, Start);
break;
1948 case "SPACER": Result =
new Spacer(
this, Parent, Start);
break;
1949 case "SPAN": Result =
new Span(
this, Parent, Start);
break;
1950 case "STRIKE": Result =
new Strike(
this, Parent, Start);
break;
1951 case "STRONG": Result =
new Strong(
this, Parent, Start);
break;
1955 if (this.style is
null)
1956 this.style =
new LinkedList<Style>();
1957 this.style.AddLast(
Style);
1960 case "SUB": Result =
new Sub(
this, Parent, Start);
break;
1964 if (this.summary is
null)
1965 this.summary =
new LinkedList<Summary>();
1966 this.summary.AddLast(
Summary);
1969 case "SUP": Result =
new Sup(
this, Parent, Start);
break;
1970 case "TABLE": Result =
new Table(
this, Parent, Start);
break;
1971 case "TBODY": Result =
new TBody(
this, Parent, Start);
break;
1972 case "TD": Result =
new Td(
this, Parent, Start);
break;
1973 case "TEMPLATE": Result =
new Template(
this, Parent, Start);
break;
1974 case "TEXTAREA": Result =
new TextArea(
this, Parent, Start);
break;
1975 case "TFOOT": Result =
new TFoot(
this, Parent, Start);
break;
1976 case "TH": Result =
new Th(
this, Parent, Start);
break;
1977 case "THEAD": Result =
new THead(
this, Parent, Start);
break;
1981 if (this.time is
null)
1982 this.time =
new LinkedList<Time>();
1983 this.time.AddLast(
Time);
1989 if (this.title is
null)
1993 case "TR": Result =
new Tr(
this, Parent, Start);
break;
1994 case "TRACK": Result =
new Track(
this, Parent, Start);
break;
1995 case "TT": Result =
new Tt(
this, Parent, Start);
break;
1996 case "U": Result =
new U(
this, Parent, Start);
break;
1997 case "UL": Result =
new Ul(
this, Parent, Start);
break;
1998 case "VAR": Result =
new Var(
this, Parent, Start);
break;
2002 if (this.video is
null)
2003 this.video =
new LinkedList<Elements.Video>();
2004 this.video.AddLast(
Video);
2007 case "WBR": Result =
new Wbr(
this, Parent, Start);
break;
2008 case "XMP": Result =
new Xmp(
this, Parent, Start);
break;
2009 default: Result =
new HtmlElement(
this, Parent, Start, TagName);
break;
2014 if (this.root is
null)
2018 Parent?.Add(Result);
2021 Result.EndPosition = Pos;
2060 int i =
Html.IndexOf(
"<body>", StringComparison.CurrentCultureIgnoreCase);
2062 Html =
Html.Substring(i + 6).TrimStart();
2064 i =
Html.IndexOf(
"</body>", StringComparison.CurrentCultureIgnoreCase);
2065 Html =
Html.Substring(0, i).TrimEnd();
2067 if (
Html.StartsWith(
"<section>", StringComparison.CurrentCultureIgnoreCase) &&
2068 Html.EndsWith(
"</section>", StringComparison.CurrentCultureIgnoreCase))
2070 string Html2 =
Html.Substring(9).TrimStart();
2071 Html2 = Html2.Substring(0, Html2.Length - 10).TrimEnd();
2073 if (!Html2.Contains(
"<section>"))
Represents a DTD instruction inside the document.
Audio(HtmlDocument Document, HtmlElement Parent, int StartPosition)
AUDIO element
Html(HtmlDocument Document, HtmlElement Parent, int StartPosition)
HTML element
Script(HtmlDocument Document, HtmlElement Parent, int StartPosition)
SCRIPT element
Video(HtmlDocument Document, HtmlElement Parent, int StartPosition)
VIDEO element
IEnumerable< Elements.Audio > Audio
AUDIO elements found in document, or null if none found.
IEnumerable< Main > Main
HEADER elements found in document, or null if none found.
Head Head
First HEAD element of document, if found, null otherwise.
HtmlDocument(string Html)
HTML document.
HtmlElement Root
Root element.
IEnumerable< Style > Style
STYLE elements found in document, or null if none found.
IEnumerable< Nav > Nav
NAV elements found in document, or null if none found.
void Export(StringBuilder Output)
Exports the HTML document to XML.
IEnumerable< Figure > Figure
FIGURE elements found in document, or null if none found.
static string GetBody(string Html)
Extracts the contents of the BODY element in a HTML string.
void Export(XmlWriter Output)
Exports the HTML document to XML.
IEnumerable< Time > Time
TIME elements found in document, or null if none found.
IEnumerable< Article > Article
ARTICLE elements found in document, or null if none found.
IEnumerable< Picture > Picture
PICTURE elements found in document, or null if none found.
IEnumerable< ProcessingInstruction > ProcessingInstructions
Processing instructions found in document, or null if none found.
Title Title
First TITLE element of document, if found, null otherwise.
IEnumerable< Address > Address
ADDRESS elements found in document, or null if none found.
IEnumerable< Details > Details
DETAILS elements found in document, or null if none found.
IEnumerable< Aside > Aside
ASIDE elements found in document, or null if none found.
IEnumerable< Dialog > Dialog
DIALOG elements found in document, or null if none found.
string HtmlText
HTML text.
IEnumerable< Elements.Script > Script
SCRIPT elements found in document, or null if none found.
PageMetaData GetMetaData()
Gets meta-data about the page.
IEnumerable< Elements.Video > Video
VIDEO elements found in document, or null if none found.
IEnumerable< Header > Header
HEADER elements found in document, or null if none found.
IEnumerable< DtdInstruction > Dtd
DTD instructions found in document, or null if none found.
IEnumerable< Meta > Meta
META elements found in document, or null if none found.
IEnumerable< Summary > Summary
SUMMARY elements found in document, or null if none found.
Elements.Html Html
First HTML element of document, if found, null otherwise.
IEnumerable< Img > Img
IMG elements found in document, or null if none found.
Body Body
First BODY element of document, if found, null otherwise.
IEnumerable< Link > Link
LINK elements found in document, or null if none found.
IEnumerable< Form > Form
FORM elements found in document, or null if none found.
IEnumerable< Footer > Footer
FOOTER elements found in document, or null if none found.
IEnumerable< Data > Data
DATA elements found in document, or null if none found.
IEnumerable< Section > Section
SECTION elements found in document, or null if none found.
IEnumerable< Cite > Cite
CITE elements found in document, or null if none found.
Base class for all HTML elements.
virtual bool IsEmptyElement
If the element is an empty element.
override void Export(XmlWriter Output)
Exports the HTML document to XML.
override string ToString()
HTML Entity, as a unicode number string.
int EndPosition
End position of element.
Contains meta-data about a page.
Represents a Processing instruction inside the document.