WooCommerce Code Reference

Dom_Document_Helper
in package

This class should guarantee that our work with the DOMDocument is unified and safe.

Table of Contents

$dom  : DOMDocument
Instance of the DOMDocument.
__construct()  : mixed
Constructor.
find_element()  : DOMElement|null
Searches for the first appearance of the given tag name.
get_attribute_value()  : string
Returns the value of the given attribute from the given element.
get_attribute_value_by_tag_name()  : string|null
Searches for the first appearance of the given tag name and returns the value of specified attribute.
get_element_inner_html()  : string
Returns the inner HTML of the given element.
get_outer_html()  : string
Returns the outer HTML of the given element.
load_html()  : void
Loads the given HTML content into the DOMDocument.

Properties

Methods

get_attribute_value()

Returns the value of the given attribute from the given element.

public get_attribute_value(DOMElement $element, string $attribute) : string
Parameters
$element : DOMElement

The element to get the attribute value from.

$attribute : string

The attribute to get the value from.

Return values
string

get_attribute_value_by_tag_name()

Searches for the first appearance of the given tag name and returns the value of specified attribute.

public get_attribute_value_by_tag_name(string $tag_name, string $attribute) : string|null
Parameters
$tag_name : string

The tag name to search for.

$attribute : string

The attribute to get the value from.

Return values
string|null