HTMLElement Reference

HTMLElement is an AppleScript libraryt that represets HTML document structure with programming.

You can built a structre of a HTML document by script object through well arranged object orientied interface. And the object structre can output well fomatted HTML data.

This library is useful when a kind of data is converted into HTML data.

The root object of HTMLElement can be made by the constructor method of make_with. First argument of make_with is name of the tag. Attributes of the tag can be specified in second argument as a list of lists e.g. {{attribute1, value1}, {attribute2, value2}, ...}.

Child objects can be appended by methods of push_element_with, push_comment_with.

The contents of HTML tags can be appended by push.

To obtain text data of HTML, as_html can be used.

use HTMLElement : script "HTMLElement"

tell HTMLElement's make_with("html", {})
tell push_element_with("head", {})
tell push_element_with("title", {})
push("Welcome to HTMLElement")
end tell
end tell
tell push_element_with("body", {})
tell push_element_with("p", {})
end tell
set body_tag to it
end tell
set html_tag to it
end tell

set comment_tag to HTMLElement's comment_with("this is comment", {})
body_tag's push(comment_tag)

log html_tag's as_html()
<title>Welcome to HTMLElement</title>
<!-- this is comment -->

Constructor Methods


Make a new HTMLElement instance


Make a new HTMLElement instance for a comment tag

Appending Child Element and Contents


Append text into the contents of the tag.


Append a new HTMLElement instance as a child node.


Append a new comment instance as a child node.



Return HTML text data.

Accessor Methods


Retun element name.


Set element name.


Return atttibute value of specified name.


Set attibute of the tag.