amt Wed Mar 10 01:33:25 2004 EDT
Modified files: /phpdoc/en/reference/simplexml reference.xml Log: Fix errors and add "Comparing Elements and Attributes with Text" section. http://cvs.php.net/diff.php/phpdoc/en/reference/simplexml/reference.xml?r1=1.8&r2=1.9&ty=u Index: phpdoc/en/reference/simplexml/reference.xml diff -u phpdoc/en/reference/simplexml/reference.xml:1.8 phpdoc/en/reference/simplexml/reference.xml:1.9 --- phpdoc/en/reference/simplexml/reference.xml:1.8 Fri Feb 6 15:18:39 2004 +++ phpdoc/en/reference/simplexml/reference.xml Wed Mar 10 01:33:25 2004 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <reference id="ref.simplexml"> <title>SimpleXML functions</title> <titleabbrev>SimpleXML</titleabbrev> @@ -51,7 +51,7 @@ </character> <character> <name>Mr. Coder</name> - <actor>El Actór</actor> + <actor>El ActÓr</actor> </character> </characters> <plot> @@ -128,7 +128,7 @@ /* Access the <rating> nodes of the first movie. * Output the rating scale, too. */ foreach ($xml->movie[0]->rating as $rating) { - switch($rating['type']) { // Get attributes as element indices + switch((string) $rating['type']) { // Get attributes as element indices case 'thumbs': echo $rating, ' thumbs up'; break; @@ -144,6 +144,28 @@ </para> <para> <example> + <title>Comparing Elements and Attributes with Text</title> + <simpara> + To compare an element with a string or pass it into a + function, you must cast it to a string using <literal>(string)</literal>. + Otherwise, PHP treats the element as an object. + </simpara> + <programlisting role="php"><![CDATA[ +<?php +include 'example.php'; + +$xml = simplexml_load_string($xmlstr); + +if ((string) $xml->movie->title == 'PHP: Behind the Parser') { + print 'My favorite movie.'; +} +?> +]]> + </programlisting> + </example> + </para> + <para> + <example> <title>Using Xpath</title> <simpara> SimpleXML includes builtin <acronym>Xpath</acronym> support.