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

search for in the

DOMElement::getAttribute> <DOMElement
Last updated: Fri, 20 May 2011

view this page in

DOMElement::__construct

(PHP 5)

DOMElement::__construct Crea un nuevo objeto DOMElement

Descripción

DOMElement::__construct ( string $name [, string $value [, string $namespaceURI ]] )

Crea un nuevo objeto DOMElement. Este objeto es de sólo lectura. Puede ser añadido a un documento, pero no se pueden añadir nodos adicionales a este nodo hasta que el nodo esté asociado con un documento. Para crear un nodo modificable, use DOMDocument::createElement o DOMDocument::createElementNS.

Parámetros

name

El nombre de la etiqueta del elemento. Cuando también se pasa en namespaceURI, el nombre del elemento puede tomar un prefijo para asociarlo con la URI.

value

El valor del elemento.

namespaceURI

Una URI del espacio de nombres para crear el elemento dentro de un espacio de nombres especificado.

Ejemplos

Example #1 Crear un nuevo objeto DOMElement

<?php

$dom 
= new DOMDocument('1.0''iso-8859-1');
$element $dom->appendChild(new DOMElement('root'));
$element_ns = new DOMElement('pr:node1''thisvalue''http://xyz');
$element->appendChild($element_ns);
echo 
$dom->saveXML(); /* <?xml version="1.0" encoding="utf-8"?>
<root><pr:node1 xmlns:pr="http://xyz">thisvalue</pr:node1></root> */

?>

Ver también



DOMElement::getAttribute> <DOMElement
Last updated: Fri, 20 May 2011
 
add a note add a note User Contributed Notes DOMElement::__construct
Fabian dot Blech at gmx dot de 22-Jul-2010 03:30
Remember, Dom-Nodes mustn't start with a number:

allowed:
<t12345t4>Value</t12345t4>

Not allowed:
<12345t4>VALUE</12345t4>
troelskn at gmail dot com 03-Jun-2008 02:46
Note that this function is buggy. You have to manually escape the $value argument with htmlspecialchars.
See: http://bugs.php.net/bug.php?id=31191
adar at darkpoetry dot de 07-May-2007 08:27
If you like to view an element simply do:

<?php
echo htmlentities($element->C14N());
?>

Undocumented but found ;)

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