added some details on invalid characters in XML names, changed a few cdata

lines


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@242390 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Paul Reinheimer 2007-09-10 21:24:57 +00:00
parent abc8152daf
commit 19c403ea63

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.21 $ -->
<!-- $Revision: 1.22 $ -->
<!-- Purpose: xml -->
<!-- Membership: bundled, external -->
@ -61,6 +61,9 @@ $xmlstr = <<<XML
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>
@ -84,6 +87,25 @@ $xml = new SimpleXMLElement($xmlstr);
echo $xml->movie[0]->plot; // "So this language. It's like..."
?>
]]>
</programlisting>
</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>&lt;line&gt;</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>
@ -95,7 +117,8 @@ echo $xml->movie[0]->plot; // "So this language. It's like..."
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';