mirror of
https://github.com/php/doc-es.git
synced 2026-04-24 07:38:19 +02:00
94aa3bf897
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@312057 c90b9560-bf6c-de11-be94-00142212c4b1
179 lines
4.8 KiB
XML
179 lines
4.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: ea1e3be13ad12c47b0307d0f4376d94c9e8c8acd Maintainer: agarzon Status: ready -->
|
|
<refentry xml:id="simplexmlelement.addchild" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>SimpleXMLElement::addChild</refname>
|
|
<refpurpose>
|
|
Añade un elemento hijo al nodo XML
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<modifier>public</modifier> <type>SimpleXMLElement</type><methodname>SimpleXMLElement::addChild</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 elemento hijo al nodo y retorna un SimpleXMLElement del hijo.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>name</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Nombre del elemento hijo a añadir.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>value</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Si se especifica, valor del elemento hijo.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>namespace</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Si se especifica, el namespace al que pertenece el elemento hijo.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
El método <literal>addChild</literal> retorna un objeto
|
|
<type>SimpleXMLElement</type> representando el hijo añadido al nodo XML.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<note>
|
|
<para>
|
|
Los ejemplos listados quizá incluyen <literal>example.php</literal>,
|
|
que hacen referencia a la cadena XML encontrada en el primer ejemplo
|
|
de la guía de <link linkend="simplexml.examples-basic">uso básico</link>.
|
|
</para>
|
|
</note>
|
|
<example>
|
|
<title>Añade 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 sobre Parser');
|
|
$pelicula->addChild('argumento', 'Todo sobre las personas que hacen que funcione.');
|
|
|
|
$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 type="estrellas">5</puntuacion>
|
|
</pelicula>
|
|
</peliculas>
|
|
]]>
|
|
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><methodname>SimpleXMLElement::addAttribute</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
|
|
-->
|