# US 2021/0342531 A1 · Method, apparatus, and computer-readable medium for transforming a hierarchical document object model to filter non-rendered elements

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0342531 A1
- Document ID: US20210342531A1
- Status: Published application
- Kind: A1
- Application number: 16/862,145
- Filed: 2020-04-29
- Published: 2021-11-04
- Earliest claimed: 2020-04-29
- Assignees: The Original Software Group Limited
- Applicants: The Original Software Group Ltd.
- Inventors: Christopher Colin Armitage
- Web page: https://patentgrep.com/patent/US20210342531A1

## CPC

- G06F 40/143: Markup, e.g. Standard Generalized Markup Language [SGML] or Document Type Definition [DTD]
- G06F 40/205: Parsing
- G06F 16/2456: {Join operations}
- G06F 16/986: {Document structures and storage, e.g. HTML extensions}
- G06F 40/12: Use of codes for handling textual entities
- G06F 40/14: Tree-structured documents (parsing G06F40/205; validation G06F40/226)
- G06F 40/154: Tree transformation for tree-structured or markup documents, e.g. XSLT, XSL-FO or stylesheets
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

An apparatus, computer-readable medium, and computer-implemented method for transforming a hierarchical document object model (DOM) to filter non-rendered elements, including parsing elements in a hierarchical DOM to identify one or more tags, any properties, and any values of the elements, removing invisible elements determined based on properties of each invisible element, each invisible element comprising an element of the DOM that is hidden from a user when the DOM is rendered, removing empty elements based on the tags of each element, each empty element comprising a tag without any associated values, identifying remaining elements of the hierarchical DOM that have parent elements that have been removed from the hierarchical DOM, and re-parenting the remaining elements to new parent elements remaining in the hierarchical DOM based on traversing the hierarchical DOM from each of the remaining elements.

## Claims

### Claim 1

A method executed by one or more computing devices for transforming a hierarchical document object model (DOM) to filter non-rendered elements, the method comprising:
parsing a plurality of elements in a hierarchical DOM to identify one or more tags of each element in the plurality of elements, any properties of each element in the plurality of elements, and any values of each element in the plurality of elements;
removing one or more invisible elements in the plurality of elements, the one or more invisible elements being determined based at least in part on one or more properties of each invisible element, each invisible element comprising an element of the DOM that is hidden from a user when the DOM is rendered;
removing one or more empty elements in the plurality of elements based at least in part on the one or more tags of each element in the plurality of elements, each empty element comprising a tag without any associated values;
identifying one or more remaining elements in a plurality of remaining elements of the hierarchical DOM that have one or more parent elements that have been removed from the hierarchical DOM; and
re-parenting the one or more remaining elements to one or more new parent elements remaining in the hierarchical DOM based at least in part on traversing the hierarchical DOM from each of the one or more remaining elements.

### Claim 2 (depends on 1)

The method of claim 1, wherein parsing a plurality of elements in a hierarchical document object model comprises:
storing a set of parameters defining elements that contain tabular data;
parsing one or more data table elements in the plurality of elements, the one or more data table elements having one or more tags corresponding to a data table;
comparing the one or more data table elements with the set of parameters to determine whether each data table element contains tabular data; and
designating all matching data table elements as containing tabular data and all non-matching data table elements as not containing tabular data, wherein all data table elements that are empty and that are designated as not containing tabular data are eligible for removal from the hierarchical DOM.

### Claim 3 (depends on 2)

The method of claim 2, wherein parsing a plurality of elements in a hierarchical document object model further comprises:
parsing one or more second data table elements in the plurality of elements, the one or more second data table elements having one or more second tags corresponding to a second data table;
comparing the one or more second data table elements with the set of parameters to determine whether each second data table element contains tabular data;
determining whether the data table and the second data table correspond to a single data table when the hierarchical DOM is rendered based on one or more of: matching data elements between the one or more data table elements and the one or more second data table elements or a common parent element between the one or more data table elements and the one or more second data table elements; and
merging the one or more data table elements and the one or more second data table elements based at least in part on a determination that each second data table element contains tabular data and a determination that the data table and the second data table correspond to a single data table when the hierarchical DOM is rendered, wherein merging comprises removing a parent second data table element in the one or more second data table elements and re-parenting the children of the removed parent second data table element to a parent data table element in the one or more data table elements.

### Claim 4 (depends on 1)

The method claim 1, wherein removing one or more invisible elements in the plurality of elements comprises, for each element:
determining whether the element is eligible for removal by comparing a tag of the element to a list of removable tags or a list of non-removable tags and comparing a tag of any child elements of the element to the list of removable tags or the list of non-removable tags;
determining whether the element is an invisible element based on one or more of: a display property of the element, a visibility property of the element, a height property of the element, or a width property of the element;
removing the element based at least in part on a determination that the element is eligible for removal and the element is an invisible element; and
removing any child elements of that element that inherit the display property of the element, the visibility property of the element, the height property of the element, or the width property of the element.

### Claim 5 (depends on 1)

The method of claim 1, wherein removing one or more empty elements in the plurality of elements based at least in part on the one or more tags of each element in the plurality of elements comprises, for each element:
determining whether the element is eligible for removal based on one or more of: a tag of the element, a role assigned to the element, or a removal flag corresponding to the tag, the removal flag indicating whether elements having the tag are eligible for removal;
determining whether the element has an associated data value; and
removing the element based at least in part on a determination that the element is eligible for removal and the element does not have an associated data value.

### Claim 6 (depends on 1)

The method of claim 1, further comprising:
assigning an original role to each element in the plurality of elements based at least in part on a tag of the element and a dictionary mapping a plurality of tags to a plurality of roles;
determining whether a text conversion flag corresponding to each element in the one or more remaining elements is true or false;
reassigning each element having a text conversion flag that is true from the original role to a text role;
comparing a role of each element in the plurality of remaining elements to a list of roles for which child elements are absorbed to identify at least one element for which child elements are absorbed; and
absorbing at least one child element of the at least one element by appending a textual value of the child element to the at least element and removing the child element.

### Claim 7 (depends on 1)

The method of claim 1, wherein each element has a corresponding role and wherein re-parenting the one or more remaining elements to one or more new parent elements remaining in the hierarchical DOM based at least in part on traversing the hierarchical DOM from each of the one or more remaining elements comprises, for each remaining element in the one or more remaining elements:
storing a list of roles permitted to have child elements;
determining a new parent element for the remaining element by traversing the hierarchical DOM from the remaining element until a parent element of the remaining element is reached that has a role on the list of roles that are permitted to have child elements; and
re-parenting the remaining element to the new parent element based at least in part on a determination that the parent element is permitted to have child elements.

### Claim 8

An apparatus for transforming a hierarchical document object model (DOM) to filter non-rendered elements, the apparatus comprising:
one or more processors; and
one or more memories operatively coupled to at least one of the one or more processors and having instructions stored thereon that, when executed by at least one of the one or more processors, cause at least one of the one or more processors to:
parse a plurality of elements in a hierarchical DOM to identify one or more tags of each element in the plurality of elements, any properties of each element in the plurality of elements, and any values of each element in the plurality of elements;
remove one or more invisible elements in the plurality of elements, the one or more invisible elements being determined based at least in part on one or more properties of each invisible element, each invisible element comprising an element of the DOM that is hidden from a user when the DOM is rendered;
remove one or more empty elements in the plurality of elements based at least in part on the one or more tags of each element in the plurality of elements, each empty element comprising a tag without any associated values;
identify one or more remaining elements in a plurality of remaining elements of the hierarchical DOM that have one or more parent elements that have been removed from the hierarchical DOM; and
re-parent the one or more remaining elements to one or more new parent elements remaining in the hierarchical DOM based at least in part on traversing the hierarchical DOM from each of the one or more remaining elements.

### Claim 9 (depends on 8)

The apparatus of claim 8, wherein the instructions that, when executed by at least one of the one or more processors, cause at least one of the one or more processors to parse a plurality of elements in a hierarchical document object model further cause at least one of the one or more processors to:
store a set of parameters defining elements that contain tabular data;
parse one or more data table elements in the plurality of elements, the one or more data table elements having one or more tags corresponding to a data table;
compare the one or more data table elements with the set of parameters to determine whether each data table element contains tabular data; and
designate all matching data table elements as containing tabular data and all non-matching data table elements as not containing tabular data, wherein all data table elements that are empty and that are designated as not containing tabular data are eligible for removal from the hierarchical DOM.

### Claim 10 (depends on 9)

The apparatus of claim 9, wherein the instructions that, when executed by at least one of the one or more processors, cause at least one of the one or more processors to parse a plurality of elements in a hierarchical document object model further cause at least one of the one or more processors to:
parse one or more second data table elements in the plurality of elements, the one or more second data table elements having one or more second tags corresponding to a second data table;
compare the one or more second data table elements with the set of parameters to determine whether each second data table element contains tabular data;
determine whether the data table and the second data table correspond to a single data table when the hierarchical DOM is rendered based on one or more of: matching data elements between the one or more data table elements and the one or more second data table elements or a common parent element between the one or more data table elements and the one or more second data table elements; and
merge the one or more data table elements and the one or more second data table elements based at least in part on a determination that each second data table element contains tabular data and a determination that the data table and the second data table correspond to a single data table when the hierarchical DOM is rendered, wherein merging comprises removing a parent second data table element in the one or more second data table elements and re-parenting the children of the removed parent second data table element to a parent data table element in the one or more data table elements.

### Claim 11 (depends on 8)

The apparatus of claim 8, wherein the instructions that, when executed by at least one of the one or more processors, cause at least one of the one or more processors to remove one or more invisible elements in the plurality of elements further cause at least one of the one or more processors to, for each element:
determine whether the element is eligible for removal by comparing a tag of the element to a list of removable tags or a list of non-removable tags and comparing a tag of any child elements of the element to the list of removable tags or the list of non-removable tags;
determine whether the element is an invisible element based on one or more of: a display property of the element, a visibility property of the element, a height property of the element, or a width property of the element;
remove the element based at least in part on a determination that the element is eligible for removal and the element is an invisible element; and
remove any child elements of that element that inherit the display property of the element, the visibility property of the element, the height property of the element, or the width property of the element.

### Claim 12 (depends on 8)

The apparatus of claim 8, wherein the instructions that, when executed by at least one of the one or more processors, cause at least one of the one or more processors to remove one or more empty elements in the plurality of elements based at least in part on the one or more tags of each element in the plurality of elements further cause at least one of the one or more processors to, for each element:
determine whether the element is eligible for removal based on one or more of: a tag of the element, a role assigned to the element, or a removal flag corresponding to the tag, the removal flag indicating whether elements having the tag are eligible for removal;
determine whether the element has an associated data value; and
remove the element based at least in part on a determination that the element is eligible for removal and the element does not have an associated data value.

### Claim 13 (depends on 8)

The apparatus of claim 8, wherein at least one of the one or more memories has further instructions stored thereon that, when executed by at least one of the one or more processors, cause at least one of the one or more processors to:
assign an original role to each element in the plurality of elements based at least in part on a tag of the element and a dictionary mapping a plurality of tags to a plurality of roles;
determine whether a text conversion flag corresponding to each element in the one or more remaining elements is true or false;
reassign each element having a text conversion flag that is true from the original role to a text role;
compare a role of each element in the plurality of remaining elements to a list of roles for which child elements are absorbed to identify at least one element for which child elements are absorbed; and
absorb at least one child element of the at least one element by appending a textual value of the child element to the at least element and removing the child element.

### Claim 14 (depends on 8)

The apparatus of claim 8, wherein each element has a corresponding role and wherein the instructions that, when executed by at least one of the one or more processors, cause at least one of the one or more processors to re-parent the one or more remaining elements to one or more new parent elements remaining in the hierarchical DOM based at least in part on traversing the hierarchical DOM from each of the one or more remaining elements further cause at least one of the one or more processors to, for each remaining element in the one or more remaining elements:
store a list of roles permitted to have child elements;
determine a new parent element for the remaining element by traversing the hierarchical DOM from the remaining element until a parent element of the remaining element is reached that has a role on the list of roles that are permitted to have child elements; and
re-parent the remaining element to the new parent element based at least in part on a determination that the parent element is permitted to have child elements.

### Claim 15

At least one non-transitory computer-readable medium storing computer-readable instructions that, when executed by one or more computing devices, cause at least one of the one or more computing devices to:
parse a plurality of elements in a hierarchical DOM to identify one or more tags of each element in the plurality of elements, any properties of each element in the plurality of elements, and any values of each element in the plurality of elements;
remove one or more invisible elements in the plurality of elements, the one or more invisible elements being determined based at least in part on one or more properties of each invisible element, each invisible element comprising an element of the DOM that is hidden from a user when the DOM is rendered;
remove one or more empty elements in the plurality of elements based at least in part on the one or more tags of each element in the plurality of elements, each empty element comprising a tag without any associated values;
identify one or more remaining elements in a plurality of remaining elements of the hierarchical DOM that have one or more parent elements that have been removed from the hierarchical DOM; and
re-parent the one or more remaining elements to one or more new parent elements remaining in the hierarchical DOM based at least in part on traversing the hierarchical DOM from each of the one or more remaining elements.

### Claim 16 (depends on 15)

The at least one non-transitory computer-readable medium of claim 15, wherein the instructions that, when executed by at least one of the one or more computing devices, cause at least one of the one or more computing devices to parse a plurality of elements in a hierarchical document object model further cause at least one of the one or more computing devices to:
store a set of parameters defining elements that contain tabular data;
parse one or more data table elements in the plurality of elements, the one or more data table elements having one or more tags corresponding to a data table;
compare the one or more data table elements with the set of parameters to determine whether each data table element contains tabular data; and
designate all matching data table elements as containing tabular data and all non-matching data table elements as not containing tabular data, wherein all data table elements that are empty and that are designated as not containing tabular data are eligible for removal from the hierarchical DOM.

### Claim 17 (depends on 16)

The at least one non-transitory computer-readable medium of claim 16, wherein the instructions that, when executed by at least one of the one or more computing devices, cause at least one of the one or more computing devices to parse a plurality of elements in a hierarchical document object model further cause at least one of the one or more computing devices to:
parse one or more second data table elements in the plurality of elements, the one or more second data table elements having one or more second tags corresponding to a second data table;
compare the one or more second data table elements with the set of parameters to determine whether each second data table element contains tabular data;
determine whether the data table and the second data table correspond to a single data table when the hierarchical DOM is rendered based on one or more of: matching data elements between the one or more data table elements and the one or more second data table elements or a common parent element between the one or more data table elements and the one or more second data table elements; and
merge the one or more data table elements and the one or more second data table elements based at least in part on a determination that each second data table element contains tabular data and a determination that the data table and the second data table correspond to a single data table when the hierarchical DOM is rendered, wherein merging comprises removing a parent second data table element in the one or more second data table elements and re-parenting the children of the removed parent second data table element to a parent data table element in the one or more data table elements.

### Claim 18 (depends on 15)

The at least one non-transitory computer-readable medium of claim 15, wherein the instructions that, when executed by at least one of the one or more computing devices, cause at least one of the one or more computing devices to remove one or more invisible elements in the plurality of elements further cause at least one of the one or more computing devices to, for each element:
determine whether the element is eligible for removal by comparing a tag of the element to a list of removable tags or a list of non-removable tags and comparing a tag of any child elements of the element to the list of removable tags or the list of non-removable tags;
determine whether the element is an invisible element based on one or more of: a display property of the element, a visibility property of the element, a height property of the element, or a width property of the element;
remove the element based at least in part on a determination that the element is eligible for removal and the element is an invisible element; and
remove any child elements of that element that inherit the display property of the element, the visibility property of the element, the height property of the element, or the width property of the element.

### Claim 19 (depends on 15)

The at least one non-transitory computer-readable medium of claim 15, wherein the instructions that, when executed by at least one of the one or more computing devices, cause at least one of the one or more computing devices to remove one or more empty elements in the plurality of elements based at least in part on the one or more tags of each element in the plurality of elements further cause at least one of the one or more computing devices to, for each element:
determine whether the element is eligible for removal based on one or more of: a tag of the element, a role assigned to the element, or a removal flag corresponding to the tag, the removal flag indicating whether elements having the tag are eligible for removal;
determine whether the element has an associated data value; and
remove the element based at least in part on a determination that the element is eligible for removal and the element does not have an associated data value.

### Claim 20 (depends on 15)

The at least one non-transitory computer-readable medium of claim 15, further storing computer-readable instructions that, when executed by at least one of the one or more computing devices, cause at least one of the one or more computing devices to:
assign an original role to each element in the plurality of elements based at least in part on a tag of the element and a dictionary mapping a plurality of tags to a plurality of roles;
determine whether a text conversion flag corresponding to each element in the one or more remaining elements is true or false;
reassign each element having a text conversion flag that is true from the original role to a text role;
compare a role of each element in the plurality of remaining elements to a list of roles for which child elements are absorbed to identify at least one element for which child elements are absorbed; and
absorb at least one child element of the at least one element by appending a textual value of the child element to the at least element and removing the child element.

### Claim 21 (depends on 15)

The at least one non-transitory computer-readable medium of claim 15, wherein each element has a corresponding role and wherein the instructions that, when executed by at least one of the one or more computing devices, cause at least one of the one or more computing devices to re-parent the one or more remaining elements to one or more new parent elements remaining in the hierarchical DOM based at least in part on traversing the hierarchical DOM from each of the one or more remaining elements further cause at least one of the one or more computing devices to, for each remaining element in the one or more remaining elements:
store a list of roles permitted to have child elements;
determine a new parent element for the remaining element by traversing the hierarchical DOM from the remaining element until a parent element of the remaining element is reached that has a role on the list of roles that are permitted to have child elements; and
re-parent the remaining element to the new parent element based at least in part on a determination that the parent element is permitted to have child elements.
