---
name: "HTMLDocument.substring"
section: "3kaya"
platform: "linux"
package: "kaya"
version: "0.4.4-6.2"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/HTMLDocument.substring"
---

# HTMLDocument.substring(3kaya)

Converts a part of the document to string form

## NAME

HTMLDocument::substring - Converts a part of the document to string form

## SYNOPSIS

**String substring(** *ElementTree tree, UnicodeFormat uform=LiteralUTF8, Doctype doctype=HTML4Strict* **)**

## ARGUMENTS

**tree** An element from the document body (it may be the document body itself)

**uform** The method for displaying multibyte Unicode characters. This argument is optional, with a default of **LiteralUTF8**

**doctype** The document type declaration to assume for conversion. This need not be the same as the doctype used for the HTMLDocument, if this element tree is part of a HTMLDocument. This argument is optional, with a default of **HTML4Strict**

## DESCRIPTION

Convert a part of the document (or a fragment of HTML unconnected to the document) into String form. This can be used as an easy way of giving HTML source examples:

-

   p = addParagraph(parent,"An image: ");\
    img = addImage(p,ImageData("example.png","an example",Unspecified));\
    p2 = addParagraph(parent,"HTML code for the image: "+substring(img));

## AUTHORS

Kaya standard library by Edwin Brady, Chris Morris and others (kaya@kayalang.org). For further information see http://kayalang.org/

## LICENSE

The Kaya standard library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (version 2.1 or any later version) as published by the Free Software Foundation.

## RELATED

**HTMLDocument.Doctype (3kaya)**

**ElementTreeData.UnicodeFormat (3kaya)**

**HTMLDocument.string (3kaya)**
