# Class TTreeDocument

Description
Hierarchy
Fields
Methods
Properties

## Unit

simplehtmltreeparser

## Declaration

`type TTreeDocument = class(TTreeNode)`

## Description

No description available, ancestor TTreeNode description follows

This class representates an element of the html file

It is stored in an unusual tree representation: All elements form a linked list and the next element is the first children, or if there is none, the next node on the same level, or if there is none, the closing tag of the current parent.
E.g. an XML file like `<foo><bar>x</bar></foo>` is stored as a quadro-linked list:

      /---------------------------------\
      |         |  -----------          |                                   link to parent (for faster access, it would work without it)
     \|/        | \|/        |          |
      '            '
    <foo> <---> <bar>  <---> x <--->  </bar>  <--->  </foo>                 double linked list of tags (previous link again for faster access, a single linked list would work as well)
      .           .                     .               .
     /|\         /|\                   /|\             /|\
      |           -----------------------               |                   single linked of corresponding node
      ---------------------------------------------------

There are functions (getNextSibling, getFirstChild, findNext, ...) to access it like a regular tree, but it is easier and faster to work directly with the list.
Some invariants: (SO: set of opening tags in sequence)
∀a \in SO: a < a.reverse
∀a,b \in SO: a < b < a.reverse => a < b.reverse < a.reverse
Attributes should be accessed with the getAttribute or getAttributeTry method. Or you can enumerate them all `for attrib in attributes`, if attributes is not nil.
#)

## Hierarchy

- TObject
- TTreeNode
- TTreeDocument

## Overview

### Methods

| `constructor create(aNodeClass: TTreeNodeClass); reintroduce;`
| `function createNode: TTreeNode;`
| `function createNode(atyp: TTreeNodeType; avalue: string = ''): TTreeNode;`
| `function createAttribute(const aname, avalue: string): TTreeAttribute;`
| `function createElementPair(const anodename: string): TTreeNode;`
| `function clone: TTreeDocument; overload;`
| `function addNamespace(const url, prefix: string): TNamespace;`
| `procedure addNamespace(const ns: TNamespace);`
| `function getEncoding: TSystemCodePage; deprecated 'support for different encodings is being removed, everything should be set to utf8';`
| `procedure addRef;`
| `procedure release;`
| `procedure FreeInstance; override;`
| `destructor destroy; override;`

### Properties

| `property baseURI: string read FBaseURI write FBaseURI;`
| `property documentURI: string read FDocumentURI write FDocumentURI;`
| `property baseEncoding: TSystemCodePage read FBaseEncoding write FBaseEncoding;`

## Description

### Methods

| `constructor create(aNodeClass: TTreeNodeClass); reintroduce;`

| `function createNode: TTreeNode;`

| `function createNode(atyp: TTreeNodeType; avalue: string = ''): TTreeNode;`

| `function createAttribute(const aname, avalue: string): TTreeAttribute;`

| `function createElementPair(const anodename: string): TTreeNode;`

| `function clone: TTreeDocument; overload;`

| `function addNamespace(const url, prefix: string): TNamespace;`

| `procedure addNamespace(const ns: TNamespace);`

| `function getEncoding: TSystemCodePage; deprecated 'support for different encodings is being removed, everything should be set to utf8';`
Warning: this symbol is deprecated: support for different encodings is being removed, everything should be set to utf8

| `procedure addRef;`

| `procedure release;`

| `procedure FreeInstance; override;`

| `destructor destroy; override;`

### Properties

| `property baseURI: string read FBaseURI write FBaseURI;`

| `property documentURI: string read FDocumentURI write FDocumentURI;`

| `property baseEncoding: TSystemCodePage read FBaseEncoding write FBaseEncoding;`

Generated by PasDoc 0.16.0.