Class: shaka.util.XmlUtils

A set of XML utility functions.

Source:

Methods

(static) findChild(elemnon-null, name) → {Element}

Finds a child XML element.
Parameters:
Name Type Description
elem Element The parent XML element.
name string The child XML element's tag name.
Source:
Returns:
The child XML element, or null if a child XML element does not exist with the given tag name OR if there exists more than one child XML element with the given tag name.
Type
Element

(static) findChildren(elemnon-null, name) → (non-null) {Array.<!Element>}

Finds child XML elements.
Parameters:
Name Type Description
elem Element The parent XML element.
name string The child XML element's tag name.
Source:
Returns:
The child XML elements.
Type
Array.<!Element>

(static) getContents(elemnon-null) → (nullable) {string}

Gets the text contents of a node.
Parameters:
Name Type Description
elem Element The XML element.
Source:
Returns:
The text contents, or null if there are none.
Type
string

(static) parseAttr(elemnon-null, name, parseFunction, opt_defaultValueopt) → {T|null}

Parses an attribute by its name.
Parameters:
Name Type Attributes Description
elem Element The XML element.
name string The attribute name.
parseFunction function(string): (T|null) A function that parses the attribute.
opt_defaultValue T | null <optional>
The attribute's default value, if not specified, the attibute's default value is null.
Source:
Returns:
The parsed attribute on success, or the attribute's default value if the attribute does not exist or could not be parsed.
Type
T | null

(static) parseDate(dateString) → (nullable) {number}

Parses an XML date string.
Parameters:
Name Type Description
dateString string
Source:
Returns:
The parsed date in seconds on success; otherwise, return null.
Type
number

(static) parseDuration(durationString) → (nullable) {number}

Parses an XML duration string. Negative values are not supported. Years and months are treated as exactly 365 and 30 days respectively.
Parameters:
Name Type Description
durationString string The duration string, e.g., "PT1H3M43.2S", which means 1 hour, 3 minutes, and 43.2 seconds.
Source:
See:
Returns:
The parsed duration in seconds on success; otherwise, return null.
Type
number

(static) parseFloat(floatString) → (nullable) {number}

Parses a floating point number.
Parameters:
Name Type Description
floatString string The floating point number string.
Source:
Returns:
The parsed floating point number on success; otherwise, return null. May return NEGATIVE_INFINITY or POSITIVE_INFINITY.
Type
number

(static) parseInt(intString) → (nullable) {number}

Parses an integer.
Parameters:
Name Type Description
intString string The integer string.
Source:
Returns:
The parsed integer on success; otherwise, return null.
Type
number

(static) parseNonNegativeInt(intString) → (nullable) {number}

Parses a non-negative integer.
Parameters:
Name Type Description
intString string The integer string.
Source:
Returns:
The parsed non-negative integer on success; otherwise, return null.
Type
number

(static) parsePositiveInt(intString) → (nullable) {number}

Parses a positive integer.
Parameters:
Name Type Description
intString string The integer string.
Source:
Returns:
The parsed positive integer on success; otherwise, return null.
Type
number

(static) parseRange(rangeString) → (nullable) {?{start: number, end: number}}

Parses a range string.
Parameters:
Name Type Description
rangeString string The range string, e.g., "101-9213".
Source:
Returns:
The parsed range on success; otherwise, return null.
Type
?{start: number, end: number}