PHP 8.3.4 Released!

DOMElement::setAttributeNS

(PHP 5, PHP 7, PHP 8)

DOMElement::setAttributeNSAdiciona um novo atributo

Descrição

public DOMElement::setAttributeNS(?string $namespace, string $qualifiedName, string $value): void

Define um atributo com namespace namespace e nome qualifiedName para o valor fornecido. Se o atributo não existir, ele será criado.

Parâmetros

namespace

O URI do namespace.

qualifiedName

O nome qualificado do atributo, comoprefix:tagname.

value

O valor do atributo.

Valor Retornado

Nenhum valor é retornado.

Erros/Exceções

DOM_NO_MODIFICATION_ALLOWED_ERR

Gerado se o nó for somente leitura.

DOM_NAMESPACE_ERR

Gerado se qualifiedName for um nome qualificado mal formado, ou se qualifiedName tiver um prefixo e namespace for null.

Veja Também

add a note

User Contributed Notes 1 note

up
6
catalinenache78 at gmail dot com
12 years ago
To add new brand xml namespace use:

<?php
$element
->setAttributeNS(
'http://www.w3.org/2000/xmlns/', // xmlns namespace URI
'xmlns:mynamespace',
'example.com/mynamespace'
);
?>

'http://www.w3.org/2000/xmlns/' URI is important
to be able to add new namespaces !!!

Later you can use your namespace like:

<?php
$element
->setAttributeNS(
'example.com/mynamespace',
'mynamespace:something',
'value'
);
?>
To Top