class Ns (View source)

Provides tools for managing and working with XML namespaces.

Traits

Shared code for working with DOMDocument objects.
Shared code for working with the logger.

Properties

protected DOMDocument $domDocument The DOMDocument object which is being used to parse the content. from DomDocumentTrait
protected LoggerInterface $logger A PSR-3 logger. from LoggerTrait
protected array $mapping A mapping of namespace URIs to preferred namespace aliases.

Methods

getDomDocument()

Gets the DOMDocument object which is being used to parse the content.

setLogger(LoggerInterface $logger)

Sets the PSR-3 logger.

getLogger()

Retrieves the PSR-3 logger.

__construct(DOMDocument $dom)

Constructs a new instance of this class.

array
addAliases(array $aliases)

Adds new aliases to this list of aliases. Set an associative array where the key is the namespace URI and the namespace alias as the value.

array
getDocNamespaces()

Gets the list of document-defined namespace aliases and namespace URIs.

string
getPreferredNamespaceAlias(string|null $namespaceUri = null)

Gets the preferred namespace alias for a particular feed dialect.

Details

DOMDocument getDomDocument()

Gets the DOMDocument object which is being used to parse the content.

Return Value

DOMDocument

LoggerTrait setLogger(LoggerInterface $logger)

Sets the PSR-3 logger.

Parameters

LoggerInterface $logger A PSR-3 compatible logger.

Return Value

LoggerTrait

LoggerInterface getLogger()

Retrieves the PSR-3 logger.

Return Value

LoggerInterface

__construct(DOMDocument $dom)

Constructs a new instance of this class.

Parameters

DOMDocument $dom A DOMDocument object representing the XML file to be parsed.

array addAliases(array $aliases)

Adds new aliases to this list of aliases. Set an associative array where the key is the namespace URI and the namespace alias as the value.

Parameters

array $aliases An associative array of namespace URIs to namespace aliases.

Return Value

array The updated list of namespace aliases.

array getDocNamespaces()

Gets the list of document-defined namespace aliases and namespace URIs.

Return Value

array

string getPreferredNamespaceAlias(string|null $namespaceUri = null)

Gets the preferred namespace alias for a particular feed dialect.

Parameters

string|null $namespaceUri The namespace URI used inside the XML document. If the value is null, then the preferred namespace alias of the root namespace will be returned. The default value is null.

Return Value

string