// Initialize an empty HTML document
HTMLDocument document = new HTMLDocument();

// Create a text node and add it to the document
Text text = document.createTextNode("Hello World!");
document.getBody().appendChild(text);

// Save the HTML document to the file on a disk
document.save($o("save-to-file.html"));