Thanks to some pointers on IRC this is my second attempt. Fixed spelling mistakes Moved the CDATA declarations onto their own line Replaced tabs with spaces.
paul -- Paul Reinheimer Zend Certified Engineer
Index: reference.xml =================================================================== RCS file: /repository/phpdoc/en/reference/simplexml/reference.xml,v retrieving revision 1.21 diff -u -r1.21 reference.xml --- reference.xml 20 Jun 2007 22:25:24 -0000 1.21 +++ reference.xml 7 Sep 2007 23:49:32 -0000 @@ -61,6 +61,9 @@ scripting language? All is revealed in this thrilling horror spoof of a documentary. </plot> + <great-lines> + <line>PHP solves all my web problems</line> + </great-lines> <rating type="thumbs">7</rating> <rating type="stars">5</rating> </movie> @@ -89,13 +92,33 @@ </example> </para> <para> + Accessing elements within an XML document that contain characters not permitted under + PHP's naming convention (e.g. the hyphen) can be accomplished by encapsulating the + element name within curly braces and the apostrophe. + <example> + <title>Getting <literal><line></literal></title> + <programlisting role="php"> +<![CDATA[ +<?php +include 'example.php'; + +$xml = new SimpleXMLElement($xmlstr); + +echo $xml->movie->{'great-lines'}->line;; // "PHP solves all my web problems" +?> +]]> + </programlisting> + </example> + </para> + <para> <example> <title>Accessing non-unique elements in SimpleXML</title> <simpara> When multiple instances of an element exist as children of a single parent element, normal iteration techniques apply. </simpara> - <programlisting role="php"><![CDATA[ + <programlisting role="php"> +<![CDATA[ <?php include 'example.php';