Forum und email

DOMAttr->__construct()

(PHP 5)

DOMAttr->__construct() — Crea un nuovo oggetto DOMAttr

Descrizione

DOMAttr
__construct ( string $name [, string $value ] )

Crea un nuovo oggetto DOMAttr. Questo oggetto è in sola lettura. Può essere aggiunto al documento, ma non vi possono essere aggiunti nodi fino a quando DOMDocument->createAttribute().

Elenco dei parametri

name

Nome tag dell'attributo- The tag name of the attribute.

value

Valore dell'attributo.

Esempi

Example#1 Esempio di creazione di un nuovo DOMAttr

<?php

$dom 
= new DOMDocument('1.0''iso-8859-1');
$element $dom->appendChild(new DOMElement('root'));
$attr $element->setAttributeNode(new DOMAttr('attr''attrvalue'));
echo 
$dom->saveXML(); /* <?xml version="1.0" encoding="iso-8859-1"?><root attr="attrvalue" /> */

?>