Working with HTML Documents in Java

The Working with HTML Documents section explains how to create, load, edit, configure, and save documents with Aspose.HTML for Java. These articles cover document-level operations with the HTML Document Object Model (DOM), CSS, linked resources, and the processing environment.

Use HTMLDocument to create or load HTML, access and modify the DOM, and save the result with save(). Create a Configuration before loading the document when you need custom fonts, character encoding, script restrictions, runtime settings, or network handling.

Choose a Document Workflow

Typical Java HTML Document Workflow

Most document-processing tasks follow the same sequence:

  1. Identify whether the input is a local file, URL, HTML string, stream, or a document created from scratch.
  2. Create a Configuration first if loading or processing requires custom services, security restrictions, fonts, encoding, or network behavior.
  3. Create or load an HTMLDocument and access its DOM tree.
  4. Read or modify elements, attributes, text, CSS, and linked resources.
  5. Save the document with HTMLDocument.save() or pass it to a converter when the required output is PDF, XPS, DOCX, or an image format.

This distinction is important: saving preserves or serializes the document and its resources, while conversion renders or transforms the content into another output format.

Main APIs Covered in This Section

Practical HTML Editing Guides

Related Sections

Try Online HTML Applications

Use the free HTML Web Applications for quick document conversion, merging, encoding, data extraction, and web-page analysis without installing software. Use Aspose.HTML for Java when these workflows must run programmatically in an application or service.

HTML Web Applications