1
0
mirror of https://github.com/php/doc-es.git synced 2026-03-26 08:22:08 +01:00
Files
archived-doc-es/reference/simplexml/simplexmlelement/addAttribute.xml
Pedro Antonio Gil Rodríguez e3fa84ded5 Corregido Error #66699
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@333728 c90b9560-bf6c-de11-be94-00142212c4b1
2014-06-08 12:10:03 +00:00

180 lines
4.7 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 8263f53d86f037f8b6d15ec61d3bfb95720dacb5 Maintainer: seros Status: ready -->
<!-- Reviewed: yes Maintainer: seros -->
<refentry xml:id="simplexmlelement.addattribute" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>SimpleXMLElement::addAttribute</refname>
<refpurpose>
Añade un atributo al elemento SimpleXML
</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>SimpleXMLElement::addAttribute</methodname>
<methodparam><type>string</type><parameter>name</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>value</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>namespace</parameter></methodparam>
</methodsynopsis>
<para>
Añade un atributo al elemento SimpleXML.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>name</parameter></term>
<listitem>
<para>
El nombre del atributo a añadir.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
El valor del atributo.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>namespace</parameter></term>
<listitem>
<para>
Si se especifica, indica el espacio de nombres al que pertenece el atributo.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.void;
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<note>
<para>
Los ejemplos enumerados podrían incluir <literal>example.php</literal>,
que hace referencia al string XML encontrado en el primer ejemplo
de la guía de <link linkend="simplexml.examples-basic">uso básico</link>.
</para>
</note>
<example>
<title>Añadir atributos e hijos a un elemento SimpleXML</title>
<programlisting role="php">
<![CDATA[
<?php
include 'example.php';
$sxe = new SimpleXMLElement($xmlstr);
$sxe->addAttribute('tipo', 'documental');
$pelicula = $sxe->addChild('pelicula');
$pelicula->addChild('titulo', 'PHP2: Más historias del Parser');
$pelicula->addChild('argumento', 'Todo sobre la gente que lo hace funcionar.');
$personajes = $pelicula->addChild('personajes');
$personaje = $personajes->addChild('personaje');
$personaje->addChild('nombre', 'Sr. Parser');
$personaje->addChild('actor', 'John Doe');
$puntuacion = $pelicula->addChild('puntuacion', '5');
$puntuacion->addAttribute('tipo', 'estrellas');
echo $sxe->asXML();
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
<?xml version="1.0" standalone="yes"?>
<peliculas tipo="documental">
<pelicula>
<titulo>PHP: Tras el Parser</titulo>
<personajes>
<personaje>
<nombre>Srta. Programadora</nombre>
<actor>Onlivia Actora</actor>
</personaje>
<personaje>
<nombre>Sr. Programador</nombre>
<actor>El Actor</actor>
</personaje>
</personajes>
<argumento>
Así que, este lenguaje. Es como, un lenguaje de programación. ¿O es un
lenguaje interpretado? Lo descubrirás en esta intrigante y temible parodia
de un documental.
</argumento>
<grandes-lineas>
<linea>PHP soluciona todos los problemas web</linea>
</grandes-lineas>
<puntuacion tipo="pulgares">7</puntuacion>
<puntuacion tipo="estrellas">5</puntuacion>
</pelicula>
<pelicula>
<titulo>PHP2: Más historias del Parser</titulo>
<argumento>Todo sobre la gente que lo hace funcionar.</argumento>
<personajes>
<personaje>
<nombre>Sr. Parser</nombre>
<actor>John Doe</actor>
</personaje>
</personajes>
<puntuacion tipo="estrellas">5</puntuacion>
</pelicula>
</peliculas>
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><methodname>SimpleXMLElement::addChild</methodname></member>
<member><xref linkend="simplexml.examples-basic"/></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->