note 87249 added to book.simplexml
| From: | bxt at die-optimisten dot net | Date: | Wed, 26 Nov 2008 15:47:43 +0000 |
| Subject: | note 87249 added to book.simplexml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-146989@lists.php.net to get a copy of this message | ||
Addition to QLeap's post:
SimpleXML will return a reference to an object containing the node value and you can't use
references in session variables as there is no feasible way to restore a reference to another
variable.
This won't work too:
$val=$this->xml->node->attributes()->name;
echo $array[$val]; // will cause a warning because of the wrong index type.
You have to convert/cast to a String first:
echo $array[(string)$val];
This will work as expected, because converting will call the __toString() method. Therefor echo
works too:
echo $val; // will display the name
----
Server IP: 212.124.37.9
Probable Submitter: 92.75.59.164
----
Manual Page -- http://www.php.net/manual/en/book.simplexml.php
Edit -- https://master.php.net/note/edit/87249
Del: integrated -- https://master.php.net/note/delete/87249/integrated
Del: useless -- https://master.php.net/note/delete/87249/useless
Del: bad code -- https://master.php.net/note/delete/87249/bad+code
Del: spam -- https://master.php.net/note/delete/87249/spam
Del: non-english -- https://master.php.net/note/delete/87249/non-english
Del: in docs -- https://master.php.net/note/delete/87249/in+docs
Del: other reasons-- https://master.php.net/note/delete/87249
Reject -- https://master.php.net/note/reject/87249
Search -- https://master.php.net/manage/user-notes.php