Long time reader, first time poster.

Rasmus, I noticed your var_dump says $x->node->title is of string(6) ... though I count only 5. Just wondering, a simple typo or something more involved?

Regards,
John

Rasmus Lerdorf wrote:
Sterling Hughes wrote:

Hm - that shouldn't be.
I think the right solution is that media:title should not show up in
the children of node, unless you are looking at the proper namespace,
ie, you need to use children() to get the children in that namespace.


Ah, you are right.  It's the damn var_dump() problem again.
eg.

$xml = <<<EOF
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss";>
 <node>
  <title>Title</title>
  <media:title>Media Title</media:title>
 </node>
</rss>
EOF;
$x = simplexml_load_string($xml);

var_dump($x->node) shows:

object(SimpleXMLElement)#2 (1) {
  ["title"]=>
  array(2) {
    [0]=>
    string(6) "Title"
    [1]=>
    string(11) "Media Title"
  }
}

but var_dump($x->node->title) shows:

object(SimpleXMLElement)#4 (1) {
  [0]=>
  string(6) "Title"
}

There should be a simplexml_dump() or something along those lines and
perhaps even a warning in var_dump() when it tries to dump an object
that has its own iterator.

-Rasmus

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to