cvs: phpdoc-es / language-defs.ent translation.xml /features cookies.xml /reference/simplexml .cvsignore configure.xml reference.xml
/reference/simplexml/functions simplexml-element-asXML.xml simplexml-element-attributes.xml simplexml-element-children.xml simplexml-element-xpath.xml
simplexml-import-dom.xml simplexml-load-file.xml simplexml-load-string.xml
| From: | Carlos Ballesteros Velasco | Date: | Mon, 05 Sep 2005 20:31:23 +0000 |
| Subject: | cvs: phpdoc-es / language-defs.ent translation.xml /features cookies.xml /reference/simplexml .cvsignore configure.xml reference.xml /reference/simplexml/functions simplexml-element-asXML.xml simplexml-element-attributes.xml simplexml-element-children.xml simplexml-element-xpath.xml simplexml-import-dom.xml simplexml-load-file.xml simplexml-load-string.xml |
||
| Groups: | php.doc.es | ||
| Request: | Send a blank email to doc-es+get-1258@lists.php.net to get a copy of this message | ||
soywiz Mon Sep 5 16:31:23 2005 EDT
Added files:
/phpdoc-es/reference/simplexml .cvsignore configure.xml
reference.xml
/phpdoc-es/reference/simplexml/functions
simplexml-element-asXML.xml
simplexml-element-attributes.xml
simplexml-element-children.xml
simplexml-element-xpath.xml
simplexml-import-dom.xml
simplexml-load-file.xml
simplexml-load-string.xml
Modified files:
/phpdoc-es/features cookies.xml
/phpdoc-es language-defs.ent translation.xml
Log:
Restaurado el "mantainer" de cookies.xml. Cambiado "requirimientos" por
"requisitos" en language-defs.ent. Añadido los ficheros de simplexml en
"translation.xml". Añadido reference/simplexml/ con una traducción preeliminar.
http://cvs.php.net/diff.php/phpdoc-es/features/cookies.xml?r1=1.10&r2=1.11&ty=u Index: phpdoc-es/features/cookies.xml diff -u phpdoc-es/features/cookies.xml:1.10 phpdoc-es/features/cookies.xml:1.11 --- phpdoc-es/features/cookies.xml:1.10 Mon Sep 5 12:33:57 2005 +++ phpdoc-es/features/cookies.xml Mon Sep 5 16:31:19 2005 @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> -<!-- EN-Revision: 1.20 Maintainer: soywiz Status: ready --> +<!-- $Revision: 1.11 $ --> +<!-- EN-Revision: 1.20 Maintainer: rafael Status: ready --> <chapter id="features.cookies"> <title>Cookies</title> http://cvs.php.net/diff.php/phpdoc-es/language-defs.ent?r1=1.18&r2=1.19&ty=u Index: phpdoc-es/language-defs.ent diff -u phpdoc-es/language-defs.ent:1.18 phpdoc-es/language-defs.ent:1.19 --- phpdoc-es/language-defs.ent:1.18 Tue Aug 31 05:02:59 2004 +++ phpdoc-es/language-defs.ent Mon Sep 5 16:31:21 2005 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.18 $ --> +<!-- $Revision: 1.19 $ --> <!-- EN-Revision: 1.21 Maintainer: rafael Status: ready --> <!-- Part titles used mostly in manual.xml itself --> @@ -29,7 +29,7 @@ <!-- These are used in reference/$extname/reference.xml and other supplemental files to mark section titles --> <!ENTITY reftitle.intro '<title>Introducción</title>'> -<!ENTITY reftitle.required '<title>Requirimientos</title>'> +<!ENTITY reftitle.required '<title>Requisitos</title>'> <!ENTITY reftitle.install '<title>Instalación</title>'> <!ENTITY reftitle.runtime '<title>Configuración en tiempo de ejecución</title>'> <!ENTITY reftitle.resources '<title>Tipos de recursos</title>'> http://cvs.php.net/diff.php/phpdoc-es/translation.xml?r1=1.209&r2=1.210&ty=u Index: phpdoc-es/translation.xml diff -u phpdoc-es/translation.xml:1.209 phpdoc-es/translation.xml:1.210 --- phpdoc-es/translation.xml:1.209 Mon Sep 5 12:33:59 2005 +++ phpdoc-es/translation.xml Mon Sep 5 16:31:21 2005 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- $Revision: 1.209 $ --> +<!-- $Revision: 1.210 $ --> <!DOCTYPE translation SYSTEM "../dtds/translation.dtd"> <translation> @@ -106,7 +106,23 @@ <file name="reference/misc/functions/time-sleep-until.xml" person="lboshell" type="translation" date="25.08.2005"/> - <file name="reference/simplexml/" person="soywiz" + <file name="reference/simplexml/reference.xml" person="soywiz" + type="translation" date="05.09.2005"/> + <file name="reference/simplexml/configure.xml" person="soywiz" + type="translation" date="05.09.2005"/> + <file name="reference/simplexml/functions/simplexml-element-asXML.xml" person="soywiz" + type="translation" date="05.09.2005"/> + <file name="reference/simplexml/functions/simplexml-element-attributes.xml" person="soywiz" + type="translation" date="05.09.2005"/> + <file name="reference/simplexml/functions/simplexml-element-children.xml" person="soywiz" + type="translation" date="05.09.2005"/> + <file name="reference/simplexml/functions/simplexml-element-xpath.xml" person="soywiz" + type="translation" date="05.09.2005"/> + <file name="reference/simplexml/functions/simplexml-import-dom.xml" person="soywiz" + type="translation" date="05.09.2005"/> + <file name="reference/simplexml/functions/simplexml-load-file.xml" person="soywiz" + type="translation" date="05.09.2005"/> + <file name="reference/simplexml/functions/simplexml-load-string.xml" person="soywiz" type="translation" date="05.09.2005"/> </work-in-progress> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/.cvsignore?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/.cvsignore +++ phpdoc-es/reference/simplexml/.cvsignore functions.xml http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/configure.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/configure.xml +++ phpdoc-es/reference/simplexml/configure.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <section id="simplexml.installation"> &reftitle.install; <para> La extensión SimpleXML está habilitada por defecto. Para deshabilitarla, usa la opción de configuración <option role="configure">--disable-simplexml</option>. </para> </section> <!-- 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:"../../../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 --> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/reference.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/reference.xml +++ phpdoc-es/reference/simplexml/reference.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.17 Maintainer: soywiz Status: revise --> <!-- Purpose: xml --> <!-- Membership: bundled, external --> <reference id="ref.simplexml"> <title>Funciones SimpleXML</title> <titleabbrev>SimpleXML</titleabbrev> <partintro> <section id="simplexml.intro"> &reftitle.intro; <para> La extensión SimpleXML ofrece un conjunto de herramientas simples y fáciles de usar para convertir un XML en un objeto que puede ser procesado con selectores de propiedades e iteradores de matrices. </para> </section> <section id="simplexml.requirements"> &reftitle.required; <para> La extensión SimpleXML requiere PHP 5. </para> </section> &reference.simplexml.configure; <section id="simplexml.examples"> &reftitle.examples; <para> Varios ejemplos de la referencia requieren una cadena XML. En vez de repetir esta cadena cada vez, la ponemos en un fichero php que incluiremos en cada ejemplo. éste fichero lo mostramos en la siguiente sección de ejemplo. Alternativamente, puedes crear un documento XML y cargarlo mediante la función <function>simplexml_load_file</function>. </para> <para> <example> <title>Fichero de Inclusión ejemplo.php con una cadena XML</title> <programlisting role="php" id="simplexml.examples.movie"> <![CDATA[ <?php $xmlstr = <<<XML <?xml version='1.0' standalone='yes'?> <movies> <movie> <title>PHP: Behind the Parser</title> <characters> <character> <name>Ms. Coder</name> <actor>Onlivia Actora</actor> </character> <character> <name>Mr. Coder</name> <actor>El ActÓr</actor> </character> </characters> <plot> So, this language. It's like, a programming language. Or is it a scripting language? All is revealed in this thrilling horror spoof of a documentary. </plot> <rating type="thumbs">7</rating> <rating type="stars">5</rating> </movie> </movies> XML; ?> ]]> </programlisting> </example> </para> <para> La simplicidad de SimpleXML aparece más claramente cuando se extrae una cadena o un número de un documento XML básico. <example> <title>Obteniendo <literal><plot></literal></title> <programlisting role="php"><![CDATA[ <?php include 'ejemplo.php'; $xml = simplexml_load_string($xmlstr); echo $xml->movie[0]->plot; // "So this language. It's like..." ?> ]]> </programlisting> </example> </para> <para> <example> <title>Accediendo a elementos no únicos en SimpleXML</title> <simpara> Cuando existen multiples instancias de un elemento de un mismo elemento padre, se aplican las técnicas normales de iteración. </simpara> <programlisting role="php"><![CDATA[ <?php include 'ejemplo.php'; $xml = simplexml_load_string($xmlstr); /* Para cada nodo <movie>, mostramos un <plot>. */ foreach ($xml->movie as $movie) { echo $movie->plot, '<br />'; } ?> ]]> </programlisting> </example> </para> <para> <example> <title>Usando atributos</title> <simpara> Por ahora, solo hemos cubierto la parte de leer los nombres de los elementos y sus valores. SimpleXML también puede acceder a los atributos de los elementos. Acceder a los atributos de un elemento es como acceder a los elementos de una <type>array</type>. </simpara> <programlisting role="php"> <![CDATA[ <?php include 'ejemplo.php'; $xml = simplexml_load_string($xmlstr); /* Accede a los nodos <rating> de la primera película. * Output the rating scale, too. */ foreach ($xml->movie[0]->rating as $rating) { switch((string) $rating['type']) { // Obtenemos los atributos como elementos índice case 'thumbs': echo $rating, ' thumbs up'; break; case 'stars': echo $rating, ' stars'; break; } } ?> ]]> </programlisting> </example> </para> <para> <example> <title>Comparando Elementos y Atributos con Texto</title> <simpara> Para comparar un elemento o atributo con una cadena o pasarlo a una función que requiera una cadena, debes convertirlo a cadena mediante <literal>(string)</literal>. De otra forma, PHP tratará el elemento como un objeto. </simpara> <programlisting role="php"><![CDATA[ <?php include 'ejemplo.php'; $xml = simplexml_load_string($xmlstr); if ((string) $xml->movie->title == 'PHP: Behind the Parser') { print 'Mi película favorita.'; } htmlentities((string) $xml->movie->title); ?> ]]> </programlisting> </example> </para> <para> <example> <title>Usando Xpath</title> <simpara> SimpleXML incluye soporte nativo de <acronym>Xpath</acronym>. Para encontrar todos los elementos <literal><character></literal>: </simpara> <programlisting role="php"> <![CDATA[ <?php include 'ejemplo.php'; $xml = simplexml_load_string($xmlstr); foreach ($xml->xpath('//character') as $character) { echo $character->name, 'played by ', $character->actor, '<br />'; } ?> ]]> </programlisting> <simpara> '<literal>//</literal>' sirve como comodín. Para especificar paths absolutos, hay que omitir una de las barras invertidas. </simpara> </example> </para> <para> <example> <title>Definiendo valores</title> <simpara> Los datos en SimpleXML no tienen porqué ser constantes. El objeto permite la manipulación de todos sus elementos. </simpara> <programlisting role="php"> <![CDATA[ <?php include 'ejemplo.php'; $xml = simplexml_load_string($xmlstr); $xml->movie[0]->characters->character[0]->name = 'Miss Coder'; echo $xml->asXML(); ?> ]]> </programlisting> <simpara> El código de arriba mostrará un documento XML nuevo, como el original, excepto que el nuevo XML tendrá <literal>Miss Coder</literal> en vez de <literal>Ms. Coder</literal>. </simpara> </example> </para> <para> <example> <title>Interoperabilidad con DOM</title> <simpara> PHP tiene un mecanismo para convertir nodos XML entre los formatos de SimpleXML y DOM. Este ejemplo muestra como se podría cambiar un elemento DOM a otro SimpleXML. </simpara> <programlisting role="php"> <![CDATA[ <?php $dom = new domDocument; $dom->loadXML('<books><book><title>blah</title></book></books>'); if (!$dom) { echo 'Error al parsear el documento'; exit; } $s = simplexml_import_dom($dom); echo $s->book[0]->title; ?> ]]> </programlisting> </example> </para> </section> </partintro> &reference.simplexml.functions; </reference> <!-- 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:"../../../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 --> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/functions/simplexml-element-asXML.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/functions/simplexml-element-asXML.xml +++ phpdoc-es/reference/simplexml/functions/simplexml-element-asXML.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.4 Maintainer: soywiz Status: revise --> <refentry id='function.simplexml-element-asXML'> <refnamediv> <refname>SimpleXMLElement->asXML</refname> <refpurpose> Devuelve una cadena XML basada en el elemento SimpleXML </refpurpose> </refnamediv> <refsect1> <title>Descripción</title> <methodsynopsis> <type>string</type><methodname>SimpleXMLElement->asXML</methodname> <void/> </methodsynopsis> <para> El método <literal>asXML</literal> da formato a los datos del objeto padre en XML versión 1.0. </para> <para> <example> <title>Obtener XML</title> <programlisting role="php"> <![CDATA[ <?php $string = <<<XML <a> <b> <c>text</c> <c>stuff</c> </b> <d> <c>code</c> </d> </a> XML; $xml = simplexml_load_string($string); echo $xml->asXML(); // <?xml ... <a><b><c>text</c><c>stuff</c> ... ?> ]]> </programlisting> </example> </para> <para> <literal>asXML</literal> también funciona con resultados Xpath: <example> <title> Usando asXML() en resultados <link linkend="function.simplexml-element-xpath">Xpath</link> </title> <programlisting role="php"> <![CDATA[ <?php // Continuación del ejemplo XML de arriba. /* Search for <a><b><c> */ $result = $xml->xpath('/a/b/c'); while(list( , $node) = each($result)) { echo $node->asXML(); // <c>text</c> and <c>stuff</c> } ?> ]]> </programlisting> </example> </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/functions/simplexml-element-attributes.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/functions/simplexml-element-attributes.xml +++ phpdoc-es/reference/simplexml/functions/simplexml-element-attributes.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.6 Maintainer: soywiz Status: revise --> <refentry id='function.simplexml-element-attributes'> <refnamediv> <refname>SimpleXMLElement->attributes</refname> <refpurpose> Identifica los atributos de un elemento </refpurpose> </refnamediv> <refsect1> <title>Descripción</title> <methodsynopsis> <type>SimpleXMLElement</type><methodname>simplexml_element->attributes</methodname> <methodparam choice="opt"><type>string</type><parameter>data</parameter></methodparam> </methodsynopsis> <para> Esta función porporciona atributos y valores definidos dentro de un tag xml. </para> &simplexml.iteration; <para> <example> <title>Interpretar una cadena XML</title> <programlisting role="php"> <![CDATA[ <?php $string = <<<XML <a> <foo name="one" game="lonely">1</foo> </a> XML; $xml = simplexml_load_string($string); foreach($xml->foo[0]->attributes() as $a => $b) { echo $a,'="',$b,"\"\n"; } ?> ]]> </programlisting> <para> Este script mostrará: </para> <screen> <![CDATA[ name="one" game="lonely" ]]> </screen> </example> </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/functions/simplexml-element-children.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/functions/simplexml-element-children.xml +++ phpdoc-es/reference/simplexml/functions/simplexml-element-children.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.8 Maintainer: soywiz Status: revise --> <refentry id='function.simplexml-element-children'> <refnamediv> <refname>SimpleXMLElement->children</refname> <refpurpose> Encuentra los hijos del nodo dado </refpurpose> </refnamediv> <refsect1> <title>Descripción</title> <methodsynopsis> <type>SimpleXMLElement</type><methodname>simplexml_element->children</methodname> <methodparam choice="opt"><type>string</type><parameter>nsprefix</parameter></methodparam> </methodsynopsis> <para> Este método encuentra los hijos del elemento al que pertenece. El resultado sigue las reglas de iteración habituales. </para> &simplexml.iteration; <example> <title>Recorrer una pseudo-matriz <literal>children()</literal></title> <programlisting role="php"> <![CDATA[ <?php $xml = simplexml_load_string( '<person> <child role="son"> <child role="daughter"/> </child> <child role="daughter"> <child role="son"> <child role="son"/> </child> </child> </person>'); foreach ($xml->children() as $second_gen) { echo ' The person begot a ' . $second_gen['role']; foreach ($second_gen->children() as $third_gen) { echo ' who begot a ' . $third_gen['role'] . ';'; foreach ($third_gen->children() as $fourth_gen) { echo ' and that ' . $third_gen['role'] . ' begot a ' . $fourth_gen['role']; } } } ?> ]]> </programlisting> <simpara> Este script mostrará: </simpara> <screen> <![CDATA[ The person begot a son who begot a daughter; The person begot a daughter who begot a son; and that son begot a son ]]> </screen> </example> </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/functions/simplexml-element-xpath.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/functions/simplexml-element-xpath.xml +++ phpdoc-es/reference/simplexml/functions/simplexml-element-xpath.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.4 Maintainer: soywiz Status: revise --> <refentry id='function.simplexml-element-xpath'> <refnamediv> <refname>SimpleXMLElement->xpath</refname> <refpurpose> Ejecuta una petición Xpath en la cadena XML </refpurpose> </refnamediv> <refsect1> <title>Descripción</title> <methodsynopsis> <type>array</type><methodname>SimpleXMLElement->xpath</methodname> <methodparam><type>string</type><parameter>path</parameter></methodparam> </methodsynopsis> <para> El método <literal>xpath</literal> busca en el nodo SimpleXML los hijos que emparejen con el parámetro <parameter>path</parameter> de <acronym>Xpath</acronym>. Devuelve siempre un <type>array</type> de objetos SimpleXMLElement. </para> <para> <example> <title>Xpath</title> <programlisting role="php"> <![CDATA[ <?php $string = <<<XML <a> <b> <c>text</c> <c>stuff</c> </b> <d> <c>code</c> </d> </a> XML; $xml = simplexml_load_string($string); /* Busca en <a><b><c> */ $result = $xml->xpath('/a/b/c'); while(list( , $node) = each($result)) { echo '/a/b/c: ',$node,"\n"; } /* Paths relativos también funcionan... */ $result = $xml->xpath('b/c'); while(list( , $node) = each($result)) { echo 'b/c: ',$node,"\n"; } ?> ]]> </programlisting> <para> Éste script mostrará: </para> <screen> <![CDATA[ /a/b/c: text /a/b/c: stuff b/c: text b/c: stuff ]]> </screen> <simpara> Notar que ámbos resultados son iguales. </simpara> </example> </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/functions/simplexml-import-dom.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/functions/simplexml-import-dom.xml +++ phpdoc-es/reference/simplexml/functions/simplexml-import-dom.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.8 Maintainer: soywiz Status: revise --> <refentry id='function.simplexml-import-dom'> <refnamediv> <refname>simplexml_import_dom</refname> <refpurpose> Obtiene un objeto <literal>SimpleXMLElement</literal> a partir de un nodo DOM. </refpurpose> </refnamediv> <refsect1> <title>Descripción</title> <methodsynopsis> <type>SimpleXMLElement</type><methodname>simplexml_import_dom</methodname> <methodparam><type>DOMNode</type><parameter>node</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>class_name</parameter></methodparam> </methodsynopsis> <para> <!-- same with this link --> Esta función toma un nodo de un documento <link linkend="ref.dom">DOM</link> y crea un nodo SimpleXML a partir de él. Este nuevo objeto puede usarse como un elemento SimpleXML nativo. Si ocurre algún error se devolverá &false;. </para> <!-- php5 DOM isn't documented; this depends on it... :| --> <!-- TODO: Document class_name and when it appeared. --> <example> <title>Importar DOM</title> <programlisting role="php"> <![CDATA[ <?php $dom = new domDocument; $dom->loadXML('<books><book><title>blah</title></book></books>'); if (!$dom) { echo 'Error al parsear el documento'; exit; } $s = simplexml_import_dom($dom); echo $s->book[0]->title; // blah ?> ]]> </programlisting> </example> <para> Vea también: <function>dom_import_simplexml</function>. </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/functions/simplexml-load-file.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/functions/simplexml-load-file.xml +++ phpdoc-es/reference/simplexml/functions/simplexml-load-file.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.10 Maintainer: soywiz Status: revise --> <refentry id='function.simplexml-load-file'> <refnamediv> <refname>simplexml_load_file</refname> <refpurpose> Interpreta un fichero XML en un objeto </refpurpose> </refnamediv> <refsect1> <title>Descripción</title> <methodsynopsis> <type>object</type><methodname>simplexml_load_file</methodname> <methodparam><type>string</type><parameter>filename</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>class_name</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>options</parameter></methodparam> </methodsynopsis> <para> Esta función convertirá un documento XML válido en un fichero especificado por <parameter>filename</parameter> en un <type>objeto</type> de clase <type>SimpleXMLElement</type>. Si ocurre algún error durante el acceso o la interpretación, la función devolverá &false;. </para> <para> Puedes utilizar el parámetro opcional <parameter>class_name</parameter> de forma que <function>simplexml_load_file</function> devolverá un objeto de la clase especificada. Esa clase deberí debe extender la clase <type>SimpleXMLElement</type>. </para> <para> Desde PHP 5.1.0 y Libxml 2.6.0, también puedes usar el parámetro <parameter>options</parameter> para especificar <link linkend="libxml.constants">parámetros de Libxml adicionales</link>. </para> <note> <para> Libxml 2 decodifica la URI, así que si quieres pasar e.j. <literal>b&c</literal> como parámetro URI <literal>a</literal>, tienes que llamar <literal>simplexml_load_file(rawurlencode('http://example.com/?a=' . urlencode('b&c')))</literal>. </para> </note> <para> <example> <title>Interpretar un documento XML</title> <programlisting role="php"> <![CDATA[ <?php // El fichero test.xml contiene un documento XML con el elemento raiz // y almenos un elemento /[root]/title. if (file_exists('test.xml')) { $xml = simplexml_load_file('test.xml'); var_dump($xml); } else { exit('Error al abrir test.xml.'); } ?> ]]> </programlisting> <para> Este script mostrará, si tiene éxito: </para> <screen> <![CDATA[ SimpleXMLElement Object ( [title] => Example Title ... ) ]]> </screen> <simpara> A partir de aquí, puedes puedes acceder al nodo <literal>title</literal> mediante <literal>$xml->title</literal> y a cualquier otro elemento. </simpara> </example> </para> <para> Vea también: <function>simplexml_load_string</function> </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/functions/simplexml-load-string.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/functions/simplexml-load-string.xml +++ phpdoc-es/reference/simplexml/functions/simplexml-load-string.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.9 Maintainer: soywiz Status: revise --> <refentry id='function.simplexml-load-string'> <refnamediv> <refname>simplexml_load_string</refname> <refpurpose> Interpreta una cadena XML en un objeto </refpurpose> </refnamediv> <refsect1> <title>Descripción</title> <methodsynopsis> <type>object</type><methodname>simplexml_load_string</methodname> <methodparam><type>string</type><parameter>data</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>class_name</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>options</parameter></methodparam> </methodsynopsis> <para> Esta función tomará una cadena xml válida <parameter>data</parameter> y devolverá un <type>object</type> de clase <type>SimpleXMLElement</type> con propiedades conteniendo la información del documento xml. Si ocurre cualquier error, se devolverá &false;. </para> <para> También puedes usar el parámetro opcional <parameter>class_name</parameter> de forma que <function>simplexml_load_string</function> devolverá un objeto de la clase especificada. Esa clase debe extender la clase <type>SimpleXMLElement</type>. </para> <para> Desde PHP 5.1.0 y Libxml 2.6.0, también puedes usar el parámetro <parameter>options</parameter> para especificar <link linkend="libxml.constants">parámetros de Libxml adicionales</link>. </para> <para> <example> <title>Interpreta una cadena XML</title> <programlisting role="php"> <![CDATA[ <?php $string = <<<XML <?xml version='1.0'?> <document> <title>Forty What?</title> <from>Joe</from> <to>Jane</to> <body> I know that's the answer -- but what's the question? </body> </document> XML; $xml = simplexml_load_string($string); var_dump($xml); ?> ]]> </programlisting> <para> This script will display: </para> <screen> <![CDATA[ SimpleXMLElement Object ( [title] => Forty What? [from] => Joe [to] => Jane [body] => I know that's the answer -- but what's the question? ) ]]> </screen> <simpara> A partir de aquí, puedes puedes acceder al nodo <literal>body</literal> mediante <literal>$xml->body</literal> y a cualquier otro elemento. </simpara> </example> </para> <para> Vea también: <function>simplexml_load_file</function>. </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:"../../../../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 -->
http://cvs.php.net/diff.php/phpdoc-es/features/cookies.xml?r1=1.10&r2=1.11&ty=u Index: phpdoc-es/features/cookies.xml diff -u phpdoc-es/features/cookies.xml:1.10 phpdoc-es/features/cookies.xml:1.11 --- phpdoc-es/features/cookies.xml:1.10 Mon Sep 5 12:33:57 2005 +++ phpdoc-es/features/cookies.xml Mon Sep 5 16:31:19 2005 @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.10 $ --> -<!-- EN-Revision: 1.20 Maintainer: soywiz Status: ready --> +<!-- $Revision: 1.11 $ --> +<!-- EN-Revision: 1.20 Maintainer: rafael Status: ready --> <chapter id="features.cookies"> <title>Cookies</title> http://cvs.php.net/diff.php/phpdoc-es/language-defs.ent?r1=1.18&r2=1.19&ty=u Index: phpdoc-es/language-defs.ent diff -u phpdoc-es/language-defs.ent:1.18 phpdoc-es/language-defs.ent:1.19 --- phpdoc-es/language-defs.ent:1.18 Tue Aug 31 05:02:59 2004 +++ phpdoc-es/language-defs.ent Mon Sep 5 16:31:21 2005 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.18 $ --> +<!-- $Revision: 1.19 $ --> <!-- EN-Revision: 1.21 Maintainer: rafael Status: ready --> <!-- Part titles used mostly in manual.xml itself --> @@ -29,7 +29,7 @@ <!-- These are used in reference/$extname/reference.xml and other supplemental files to mark section titles --> <!ENTITY reftitle.intro '<title>Introducción</title>'> -<!ENTITY reftitle.required '<title>Requirimientos</title>'> +<!ENTITY reftitle.required '<title>Requisitos</title>'> <!ENTITY reftitle.install '<title>Instalación</title>'> <!ENTITY reftitle.runtime '<title>Configuración en tiempo de ejecución</title>'> <!ENTITY reftitle.resources '<title>Tipos de recursos</title>'> http://cvs.php.net/diff.php/phpdoc-es/translation.xml?r1=1.209&r2=1.210&ty=u Index: phpdoc-es/translation.xml diff -u phpdoc-es/translation.xml:1.209 phpdoc-es/translation.xml:1.210 --- phpdoc-es/translation.xml:1.209 Mon Sep 5 12:33:59 2005 +++ phpdoc-es/translation.xml Mon Sep 5 16:31:21 2005 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- $Revision: 1.209 $ --> +<!-- $Revision: 1.210 $ --> <!DOCTYPE translation SYSTEM "../dtds/translation.dtd"> <translation> @@ -106,7 +106,23 @@ <file name="reference/misc/functions/time-sleep-until.xml" person="lboshell" type="translation" date="25.08.2005"/> - <file name="reference/simplexml/" person="soywiz" + <file name="reference/simplexml/reference.xml" person="soywiz" + type="translation" date="05.09.2005"/> + <file name="reference/simplexml/configure.xml" person="soywiz" + type="translation" date="05.09.2005"/> + <file name="reference/simplexml/functions/simplexml-element-asXML.xml" person="soywiz" + type="translation" date="05.09.2005"/> + <file name="reference/simplexml/functions/simplexml-element-attributes.xml" person="soywiz" + type="translation" date="05.09.2005"/> + <file name="reference/simplexml/functions/simplexml-element-children.xml" person="soywiz" + type="translation" date="05.09.2005"/> + <file name="reference/simplexml/functions/simplexml-element-xpath.xml" person="soywiz" + type="translation" date="05.09.2005"/> + <file name="reference/simplexml/functions/simplexml-import-dom.xml" person="soywiz" + type="translation" date="05.09.2005"/> + <file name="reference/simplexml/functions/simplexml-load-file.xml" person="soywiz" + type="translation" date="05.09.2005"/> + <file name="reference/simplexml/functions/simplexml-load-string.xml" person="soywiz" type="translation" date="05.09.2005"/> </work-in-progress> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/.cvsignore?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/.cvsignore +++ phpdoc-es/reference/simplexml/.cvsignore functions.xml http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/configure.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/configure.xml +++ phpdoc-es/reference/simplexml/configure.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <section id="simplexml.installation"> &reftitle.install; <para> La extensión SimpleXML está habilitada por defecto. Para deshabilitarla, usa la opción de configuración <option role="configure">--disable-simplexml</option>. </para> </section> <!-- 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:"../../../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 --> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/reference.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/reference.xml +++ phpdoc-es/reference/simplexml/reference.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.17 Maintainer: soywiz Status: revise --> <!-- Purpose: xml --> <!-- Membership: bundled, external --> <reference id="ref.simplexml"> <title>Funciones SimpleXML</title> <titleabbrev>SimpleXML</titleabbrev> <partintro> <section id="simplexml.intro"> &reftitle.intro; <para> La extensión SimpleXML ofrece un conjunto de herramientas simples y fáciles de usar para convertir un XML en un objeto que puede ser procesado con selectores de propiedades e iteradores de matrices. </para> </section> <section id="simplexml.requirements"> &reftitle.required; <para> La extensión SimpleXML requiere PHP 5. </para> </section> &reference.simplexml.configure; <section id="simplexml.examples"> &reftitle.examples; <para> Varios ejemplos de la referencia requieren una cadena XML. En vez de repetir esta cadena cada vez, la ponemos en un fichero php que incluiremos en cada ejemplo. éste fichero lo mostramos en la siguiente sección de ejemplo. Alternativamente, puedes crear un documento XML y cargarlo mediante la función <function>simplexml_load_file</function>. </para> <para> <example> <title>Fichero de Inclusión ejemplo.php con una cadena XML</title> <programlisting role="php" id="simplexml.examples.movie"> <![CDATA[ <?php $xmlstr = <<<XML <?xml version='1.0' standalone='yes'?> <movies> <movie> <title>PHP: Behind the Parser</title> <characters> <character> <name>Ms. Coder</name> <actor>Onlivia Actora</actor> </character> <character> <name>Mr. Coder</name> <actor>El ActÓr</actor> </character> </characters> <plot> So, this language. It's like, a programming language. Or is it a scripting language? All is revealed in this thrilling horror spoof of a documentary. </plot> <rating type="thumbs">7</rating> <rating type="stars">5</rating> </movie> </movies> XML; ?> ]]> </programlisting> </example> </para> <para> La simplicidad de SimpleXML aparece más claramente cuando se extrae una cadena o un número de un documento XML básico. <example> <title>Obteniendo <literal><plot></literal></title> <programlisting role="php"><![CDATA[ <?php include 'ejemplo.php'; $xml = simplexml_load_string($xmlstr); echo $xml->movie[0]->plot; // "So this language. It's like..." ?> ]]> </programlisting> </example> </para> <para> <example> <title>Accediendo a elementos no únicos en SimpleXML</title> <simpara> Cuando existen multiples instancias de un elemento de un mismo elemento padre, se aplican las técnicas normales de iteración. </simpara> <programlisting role="php"><![CDATA[ <?php include 'ejemplo.php'; $xml = simplexml_load_string($xmlstr); /* Para cada nodo <movie>, mostramos un <plot>. */ foreach ($xml->movie as $movie) { echo $movie->plot, '<br />'; } ?> ]]> </programlisting> </example> </para> <para> <example> <title>Usando atributos</title> <simpara> Por ahora, solo hemos cubierto la parte de leer los nombres de los elementos y sus valores. SimpleXML también puede acceder a los atributos de los elementos. Acceder a los atributos de un elemento es como acceder a los elementos de una <type>array</type>. </simpara> <programlisting role="php"> <![CDATA[ <?php include 'ejemplo.php'; $xml = simplexml_load_string($xmlstr); /* Accede a los nodos <rating> de la primera película. * Output the rating scale, too. */ foreach ($xml->movie[0]->rating as $rating) { switch((string) $rating['type']) { // Obtenemos los atributos como elementos índice case 'thumbs': echo $rating, ' thumbs up'; break; case 'stars': echo $rating, ' stars'; break; } } ?> ]]> </programlisting> </example> </para> <para> <example> <title>Comparando Elementos y Atributos con Texto</title> <simpara> Para comparar un elemento o atributo con una cadena o pasarlo a una función que requiera una cadena, debes convertirlo a cadena mediante <literal>(string)</literal>. De otra forma, PHP tratará el elemento como un objeto. </simpara> <programlisting role="php"><![CDATA[ <?php include 'ejemplo.php'; $xml = simplexml_load_string($xmlstr); if ((string) $xml->movie->title == 'PHP: Behind the Parser') { print 'Mi película favorita.'; } htmlentities((string) $xml->movie->title); ?> ]]> </programlisting> </example> </para> <para> <example> <title>Usando Xpath</title> <simpara> SimpleXML incluye soporte nativo de <acronym>Xpath</acronym>. Para encontrar todos los elementos <literal><character></literal>: </simpara> <programlisting role="php"> <![CDATA[ <?php include 'ejemplo.php'; $xml = simplexml_load_string($xmlstr); foreach ($xml->xpath('//character') as $character) { echo $character->name, 'played by ', $character->actor, '<br />'; } ?> ]]> </programlisting> <simpara> '<literal>//</literal>' sirve como comodín. Para especificar paths absolutos, hay que omitir una de las barras invertidas. </simpara> </example> </para> <para> <example> <title>Definiendo valores</title> <simpara> Los datos en SimpleXML no tienen porqué ser constantes. El objeto permite la manipulación de todos sus elementos. </simpara> <programlisting role="php"> <![CDATA[ <?php include 'ejemplo.php'; $xml = simplexml_load_string($xmlstr); $xml->movie[0]->characters->character[0]->name = 'Miss Coder'; echo $xml->asXML(); ?> ]]> </programlisting> <simpara> El código de arriba mostrará un documento XML nuevo, como el original, excepto que el nuevo XML tendrá <literal>Miss Coder</literal> en vez de <literal>Ms. Coder</literal>. </simpara> </example> </para> <para> <example> <title>Interoperabilidad con DOM</title> <simpara> PHP tiene un mecanismo para convertir nodos XML entre los formatos de SimpleXML y DOM. Este ejemplo muestra como se podría cambiar un elemento DOM a otro SimpleXML. </simpara> <programlisting role="php"> <![CDATA[ <?php $dom = new domDocument; $dom->loadXML('<books><book><title>blah</title></book></books>'); if (!$dom) { echo 'Error al parsear el documento'; exit; } $s = simplexml_import_dom($dom); echo $s->book[0]->title; ?> ]]> </programlisting> </example> </para> </section> </partintro> &reference.simplexml.functions; </reference> <!-- 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:"../../../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 --> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/functions/simplexml-element-asXML.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/functions/simplexml-element-asXML.xml +++ phpdoc-es/reference/simplexml/functions/simplexml-element-asXML.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.4 Maintainer: soywiz Status: revise --> <refentry id='function.simplexml-element-asXML'> <refnamediv> <refname>SimpleXMLElement->asXML</refname> <refpurpose> Devuelve una cadena XML basada en el elemento SimpleXML </refpurpose> </refnamediv> <refsect1> <title>Descripción</title> <methodsynopsis> <type>string</type><methodname>SimpleXMLElement->asXML</methodname> <void/> </methodsynopsis> <para> El método <literal>asXML</literal> da formato a los datos del objeto padre en XML versión 1.0. </para> <para> <example> <title>Obtener XML</title> <programlisting role="php"> <![CDATA[ <?php $string = <<<XML <a> <b> <c>text</c> <c>stuff</c> </b> <d> <c>code</c> </d> </a> XML; $xml = simplexml_load_string($string); echo $xml->asXML(); // <?xml ... <a><b><c>text</c><c>stuff</c> ... ?> ]]> </programlisting> </example> </para> <para> <literal>asXML</literal> también funciona con resultados Xpath: <example> <title> Usando asXML() en resultados <link linkend="function.simplexml-element-xpath">Xpath</link> </title> <programlisting role="php"> <![CDATA[ <?php // Continuación del ejemplo XML de arriba. /* Search for <a><b><c> */ $result = $xml->xpath('/a/b/c'); while(list( , $node) = each($result)) { echo $node->asXML(); // <c>text</c> and <c>stuff</c> } ?> ]]> </programlisting> </example> </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/functions/simplexml-element-attributes.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/functions/simplexml-element-attributes.xml +++ phpdoc-es/reference/simplexml/functions/simplexml-element-attributes.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.6 Maintainer: soywiz Status: revise --> <refentry id='function.simplexml-element-attributes'> <refnamediv> <refname>SimpleXMLElement->attributes</refname> <refpurpose> Identifica los atributos de un elemento </refpurpose> </refnamediv> <refsect1> <title>Descripción</title> <methodsynopsis> <type>SimpleXMLElement</type><methodname>simplexml_element->attributes</methodname> <methodparam choice="opt"><type>string</type><parameter>data</parameter></methodparam> </methodsynopsis> <para> Esta función porporciona atributos y valores definidos dentro de un tag xml. </para> &simplexml.iteration; <para> <example> <title>Interpretar una cadena XML</title> <programlisting role="php"> <![CDATA[ <?php $string = <<<XML <a> <foo name="one" game="lonely">1</foo> </a> XML; $xml = simplexml_load_string($string); foreach($xml->foo[0]->attributes() as $a => $b) { echo $a,'="',$b,"\"\n"; } ?> ]]> </programlisting> <para> Este script mostrará: </para> <screen> <![CDATA[ name="one" game="lonely" ]]> </screen> </example> </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/functions/simplexml-element-children.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/functions/simplexml-element-children.xml +++ phpdoc-es/reference/simplexml/functions/simplexml-element-children.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.8 Maintainer: soywiz Status: revise --> <refentry id='function.simplexml-element-children'> <refnamediv> <refname>SimpleXMLElement->children</refname> <refpurpose> Encuentra los hijos del nodo dado </refpurpose> </refnamediv> <refsect1> <title>Descripción</title> <methodsynopsis> <type>SimpleXMLElement</type><methodname>simplexml_element->children</methodname> <methodparam choice="opt"><type>string</type><parameter>nsprefix</parameter></methodparam> </methodsynopsis> <para> Este método encuentra los hijos del elemento al que pertenece. El resultado sigue las reglas de iteración habituales. </para> &simplexml.iteration; <example> <title>Recorrer una pseudo-matriz <literal>children()</literal></title> <programlisting role="php"> <![CDATA[ <?php $xml = simplexml_load_string( '<person> <child role="son"> <child role="daughter"/> </child> <child role="daughter"> <child role="son"> <child role="son"/> </child> </child> </person>'); foreach ($xml->children() as $second_gen) { echo ' The person begot a ' . $second_gen['role']; foreach ($second_gen->children() as $third_gen) { echo ' who begot a ' . $third_gen['role'] . ';'; foreach ($third_gen->children() as $fourth_gen) { echo ' and that ' . $third_gen['role'] . ' begot a ' . $fourth_gen['role']; } } } ?> ]]> </programlisting> <simpara> Este script mostrará: </simpara> <screen> <![CDATA[ The person begot a son who begot a daughter; The person begot a daughter who begot a son; and that son begot a son ]]> </screen> </example> </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/functions/simplexml-element-xpath.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/functions/simplexml-element-xpath.xml +++ phpdoc-es/reference/simplexml/functions/simplexml-element-xpath.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.4 Maintainer: soywiz Status: revise --> <refentry id='function.simplexml-element-xpath'> <refnamediv> <refname>SimpleXMLElement->xpath</refname> <refpurpose> Ejecuta una petición Xpath en la cadena XML </refpurpose> </refnamediv> <refsect1> <title>Descripción</title> <methodsynopsis> <type>array</type><methodname>SimpleXMLElement->xpath</methodname> <methodparam><type>string</type><parameter>path</parameter></methodparam> </methodsynopsis> <para> El método <literal>xpath</literal> busca en el nodo SimpleXML los hijos que emparejen con el parámetro <parameter>path</parameter> de <acronym>Xpath</acronym>. Devuelve siempre un <type>array</type> de objetos SimpleXMLElement. </para> <para> <example> <title>Xpath</title> <programlisting role="php"> <![CDATA[ <?php $string = <<<XML <a> <b> <c>text</c> <c>stuff</c> </b> <d> <c>code</c> </d> </a> XML; $xml = simplexml_load_string($string); /* Busca en <a><b><c> */ $result = $xml->xpath('/a/b/c'); while(list( , $node) = each($result)) { echo '/a/b/c: ',$node,"\n"; } /* Paths relativos también funcionan... */ $result = $xml->xpath('b/c'); while(list( , $node) = each($result)) { echo 'b/c: ',$node,"\n"; } ?> ]]> </programlisting> <para> Éste script mostrará: </para> <screen> <![CDATA[ /a/b/c: text /a/b/c: stuff b/c: text b/c: stuff ]]> </screen> <simpara> Notar que ámbos resultados son iguales. </simpara> </example> </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/functions/simplexml-import-dom.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/functions/simplexml-import-dom.xml +++ phpdoc-es/reference/simplexml/functions/simplexml-import-dom.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.8 Maintainer: soywiz Status: revise --> <refentry id='function.simplexml-import-dom'> <refnamediv> <refname>simplexml_import_dom</refname> <refpurpose> Obtiene un objeto <literal>SimpleXMLElement</literal> a partir de un nodo DOM. </refpurpose> </refnamediv> <refsect1> <title>Descripción</title> <methodsynopsis> <type>SimpleXMLElement</type><methodname>simplexml_import_dom</methodname> <methodparam><type>DOMNode</type><parameter>node</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>class_name</parameter></methodparam> </methodsynopsis> <para> <!-- same with this link --> Esta función toma un nodo de un documento <link linkend="ref.dom">DOM</link> y crea un nodo SimpleXML a partir de él. Este nuevo objeto puede usarse como un elemento SimpleXML nativo. Si ocurre algún error se devolverá &false;. </para> <!-- php5 DOM isn't documented; this depends on it... :| --> <!-- TODO: Document class_name and when it appeared. --> <example> <title>Importar DOM</title> <programlisting role="php"> <![CDATA[ <?php $dom = new domDocument; $dom->loadXML('<books><book><title>blah</title></book></books>'); if (!$dom) { echo 'Error al parsear el documento'; exit; } $s = simplexml_import_dom($dom); echo $s->book[0]->title; // blah ?> ]]> </programlisting> </example> <para> Vea también: <function>dom_import_simplexml</function>. </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/functions/simplexml-load-file.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/functions/simplexml-load-file.xml +++ phpdoc-es/reference/simplexml/functions/simplexml-load-file.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.10 Maintainer: soywiz Status: revise --> <refentry id='function.simplexml-load-file'> <refnamediv> <refname>simplexml_load_file</refname> <refpurpose> Interpreta un fichero XML en un objeto </refpurpose> </refnamediv> <refsect1> <title>Descripción</title> <methodsynopsis> <type>object</type><methodname>simplexml_load_file</methodname> <methodparam><type>string</type><parameter>filename</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>class_name</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>options</parameter></methodparam> </methodsynopsis> <para> Esta función convertirá un documento XML válido en un fichero especificado por <parameter>filename</parameter> en un <type>objeto</type> de clase <type>SimpleXMLElement</type>. Si ocurre algún error durante el acceso o la interpretación, la función devolverá &false;. </para> <para> Puedes utilizar el parámetro opcional <parameter>class_name</parameter> de forma que <function>simplexml_load_file</function> devolverá un objeto de la clase especificada. Esa clase deberí debe extender la clase <type>SimpleXMLElement</type>. </para> <para> Desde PHP 5.1.0 y Libxml 2.6.0, también puedes usar el parámetro <parameter>options</parameter> para especificar <link linkend="libxml.constants">parámetros de Libxml adicionales</link>. </para> <note> <para> Libxml 2 decodifica la URI, así que si quieres pasar e.j. <literal>b&c</literal> como parámetro URI <literal>a</literal>, tienes que llamar <literal>simplexml_load_file(rawurlencode('http://example.com/?a=' . urlencode('b&c')))</literal>. </para> </note> <para> <example> <title>Interpretar un documento XML</title> <programlisting role="php"> <![CDATA[ <?php // El fichero test.xml contiene un documento XML con el elemento raiz // y almenos un elemento /[root]/title. if (file_exists('test.xml')) { $xml = simplexml_load_file('test.xml'); var_dump($xml); } else { exit('Error al abrir test.xml.'); } ?> ]]> </programlisting> <para> Este script mostrará, si tiene éxito: </para> <screen> <![CDATA[ SimpleXMLElement Object ( [title] => Example Title ... ) ]]> </screen> <simpara> A partir de aquí, puedes puedes acceder al nodo <literal>title</literal> mediante <literal>$xml->title</literal> y a cualquier otro elemento. </simpara> </example> </para> <para> Vea también: <function>simplexml_load_string</function> </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:"../../../../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 --> http://cvs.php.net/co.php/phpdoc-es/reference/simplexml/functions/simplexml-load-string.xml?r=1.1&p=1 Index: phpdoc-es/reference/simplexml/functions/simplexml-load-string.xml +++ phpdoc-es/reference/simplexml/functions/simplexml-load-string.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.9 Maintainer: soywiz Status: revise --> <refentry id='function.simplexml-load-string'> <refnamediv> <refname>simplexml_load_string</refname> <refpurpose> Interpreta una cadena XML en un objeto </refpurpose> </refnamediv> <refsect1> <title>Descripción</title> <methodsynopsis> <type>object</type><methodname>simplexml_load_string</methodname> <methodparam><type>string</type><parameter>data</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>class_name</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>options</parameter></methodparam> </methodsynopsis> <para> Esta función tomará una cadena xml válida <parameter>data</parameter> y devolverá un <type>object</type> de clase <type>SimpleXMLElement</type> con propiedades conteniendo la información del documento xml. Si ocurre cualquier error, se devolverá &false;. </para> <para> También puedes usar el parámetro opcional <parameter>class_name</parameter> de forma que <function>simplexml_load_string</function> devolverá un objeto de la clase especificada. Esa clase debe extender la clase <type>SimpleXMLElement</type>. </para> <para> Desde PHP 5.1.0 y Libxml 2.6.0, también puedes usar el parámetro <parameter>options</parameter> para especificar <link linkend="libxml.constants">parámetros de Libxml adicionales</link>. </para> <para> <example> <title>Interpreta una cadena XML</title> <programlisting role="php"> <![CDATA[ <?php $string = <<<XML <?xml version='1.0'?> <document> <title>Forty What?</title> <from>Joe</from> <to>Jane</to> <body> I know that's the answer -- but what's the question? </body> </document> XML; $xml = simplexml_load_string($string); var_dump($xml); ?> ]]> </programlisting> <para> This script will display: </para> <screen> <![CDATA[ SimpleXMLElement Object ( [title] => Forty What? [from] => Joe [to] => Jane [body] => I know that's the answer -- but what's the question? ) ]]> </screen> <simpara> A partir de aquí, puedes puedes acceder al nodo <literal>body</literal> mediante <literal>$xml->body</literal> y a cualquier otro elemento. </simpara> </example> </para> <para> Vea también: <function>simplexml_load_file</function>. </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:"../../../../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 -->