downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

DOMElement::setAttributeNodeNS> <DOMElement::setAttribute
[edit] Last updated: Fri, 24 May 2013

view this page in

DOMElement::setAttributeNode

(PHP 5)

DOMElement::setAttributeNodeAñade un nuevo nodo de atributo al elemento

Descripción

DOMAttr DOMElement::setAttributeNode ( DOMAttr $attr )

Añade el nuevo nodo de atributo dado por attr al elemento.

Parámetros

attr

El nodo de atributo.

Valores devueltos

Devuelve el nodo antiguo si el atributo ha sido reemplazado o NULL.

Errores/Excepciones

DOM_NO_MODIFICATION_ALLOWED_ERR

Lanzado si el nodo es de sólo lectura.

Ver también



add a note add a note User Contributed Notes DOMElement::setAttributeNode - [1 notes]
up
0
karvjorm at users.sourceforge.net
6 years ago
$dom = new DomDocument('1.0','iso-8859-15');

$ht_ml = $dom->appendChild($dom->createElement('html'));

$he_ad = $ht_ml->appendChild($dom->createElement('head'));

$tit_le= $he_ad->appendChild($dom->createElement('title'));
$tit_le->appendChild($dom->createTextNode('DOMAttr test'));

$me_ta = $he_ad->appendChild(new DOMElement('meta'));
$me_ta->setAttributeNode(new DOMAttr('name', 'Description'));
$me_ta->setAttributeNode(new DOMAttr('content', 'example'));

$me_ta = $he_ad->appendChild(new DOMElement('meta'));
$me_ta->setAttributeNode(new DOMAttr('name', 'Author'));
$me_ta->setAttributeNode(new DOMAttr('content', 'karvjorm'));

Result:

<?xml version="1.0" encoding="iso-8859-15"?>
<html>
  <head>
    <title>DOMAttr test</title>
    <meta name="Description" content="example"/>
    <meta name="Author" content="karvjorm"/>
  </head>

 
show source | credits | sitemap | contact | advertising | mirror sites