Skip to content

Nodes RegisterNamespace

Thomas Weinert edited this page Jul 12, 2018 · 3 revisions

FluentDOM\Nodes::registerNamespace()

void registerNamespace(string $prefix, string $namespace);

Registers a namespace for the Nodes instance. The namespace will be registered on the attached Xpath instance. If the document property contains a FluentDOM\DOM\Document, the namespace will be registered here, too.

Usage

$fd = new FluentDOM\Nodes(
  '<foo:message xmlns:foo="urn:foo">Hello World!</foo:message>'
);
$fd->registerNamespace('bar', 'urn:foo');
echo $fd->find('//bar:message')[0];

Output

Hello World!
Clone this wiki locally