This GitHub gist repository features Java code examples that are referenced in the Working with Documents chapter of the Aspose.HTML for Java documentation. It is intended for Java developers looking to handle and manage HTML documents programmatically. The examples showcase the core functionalities of the Aspose.HTML for Java library, allowing you to load, manipulate, and save web content with precision and ease.
The gists in this collection cover the following key topics for working with HTML documents in Java:
- Loading HTML, EPUB, and MHTML documents from various sources.
- Creating, modifying, and deleting HTML elements dynamically.
- Navigating the Document Object Model (DOM) tree using W3C-compliant traversal interfaces to inspect and retrieve content from HTML documents.
- Customizing the rendering environment by setting user-defined style sheets, font folders, message handlers, sandboxing options, and other parameters.
- Saving HTML documents in multiple formats, including HTML, MHTML, and Markdown.
- Saving HTML documents along with all linked resources, including CSS, fonts, and images, using customizable saving options.
Each gist is a self-contained executable example. To use them:
- Make sure your Java project includes the Aspose.HTML for Java library.
- You can easily add it to your project using a dependency management tool, such as Maven or Gradle. For more detailed tutorials, see the installation guide.
- Select the code snippet that corresponds to the task you want to perform.
- Copy the example into your project and run it to see the functionality in action.
You can download a free trial of Aspose.HTML for Java and use a temporary license for unlimited access.
Aspose.HTML for Java is a robust, on-premise Java library designed for parsing, navigating, processing, and converting HTML and related formats. It offers comprehensive APIs for the Document Object Model (DOM), CSS selector queries, and XPath-style traversal helpers, which simplify the inspection, retrieval, and manipulation of content from web pages and HTML documents.
- Official Documentation – Aspose.HTML for Java
- Product page – Aspose.HTML for Java
- Blog – Aspose.HTML Product Family
- Free Support Forum – Aspose.HTML
- API Reference – Aspose.HTML for Java
To run the examples, you need:
- Java Runtime Environment: J2SE 1.8 or higher.
- Supported OS: Windows, macOS, Linux.
- Development Environment: Any Java IDE (e.g., IntelliJ IDEA, Eclipse, NetBeans).