This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

mlreportgen.dom.CustomElement class

Package: mlreportgen.dom

Custom element of document


Use a custom element to extend the DOM API. You can create a custom HTML or Microsoft® Word element that provides functionality not yet included in the DOM API.


customElementObj = CustomElement() creates an empty element.

customElementObj = CustomElement(name) creates a custom element having the specified name.

Input Arguments

expand all

Name of an element supported by the type of document to which this custom element is appended. For example, specify 'div' for a custom HTML div element or 'w:p' for a custom Word paragraph element.

Output Arguments

expand all

Custom element, represented by an mlreportgen.dom.CustomElement object.


expand all

The output format must support the custom attributes of this document element.

ID for this document element, specified as a character vector. The DOM generates a session-unique ID when it creates the document element. You can specify your own ID.

Element name, specified as a character vector.

This property is ignored.

This property is ignored.

Tag for document element, specified as a character vector.

A session-unique ID is generated as part of document element creation. The generated tag has the form CLASS:ID, where CLASS is the class of the element and ID is the value of the Id property of the object. You can specify a tag to replace the generated tag.

For example, to make it easier to identify where an issue occurred during document generation, you can specify your own tag value.





Append a custom element to the document element


Use CustomElement.clone similar to how you use Paragraph.clone.

Copy custom element.


expand all

This example shows how to add a custom element that provides a check box in an HTML report.

Create and a custom element and append text to it.

import mlreportgen.dom.*;
d = Document('test');

input1 = CustomElement('input');
input1.CustomAttributes = {
         CustomAttribute('type','checkbox'), ...
         CustomAttribute('name','vehicle'), ...
         CustomAttribute('value','Bike'), ...
append(input1, Text('I have a bike'));

Append the custom element to an ordered list and display the report.

ol = OrderedList({input1});

Was this topic helpful?