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

search for in the

DOMElement::setAttributeNodeNS> <DOMElement::setAttribute
Last updated: Fri, 20 Jun 2008

view this page in

DOMElement::setAttributeNode

(No version information available, might be only in CVS)

DOMElement::setAttributeNode — Ajoute un nouvel attribut à l'élément

Description

DOMAttr DOMElement::setAttributeNode ( DOMAttr $attr )

Ajoute un nouvel attribut attr à l'élément.

Liste de paramètres

attr

L'attribut.

Valeurs de retour

Retourne l'ancien noeud si l'attribut a été placé ou NULL.

Erreurs / Exceptions

DOM_NO_MODIFICATION_ALLOWED_ERR

Lancé si le noeud est en lecture seule.



add a note add a note User Contributed Notes
DOMElement::setAttributeNode
karvjorm at users.sourceforge.net
02-Mar-2007 04:01
$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>

DOMElement::setAttributeNodeNS> <DOMElement::setAttribute
Last updated: Fri, 20 Jun 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites