Jump to content

XML - array doesnt show entire file


Drongo_III

Recommended Posts

Hi Guys

 

I'm pulling an xml feed from Youtube to get some practice with traversing xml.

 

The thing I don't quite get is that when i create an simple xml object and do print_r (to concisely see what's in the xml)  it doesn't show everything that's in the actual xml file. Is that usual? And is using print_r on an xml object a stupid idea?

 

For instance this element is missing:

 

<media:thumbnail url="http://i.ytimg.com/vi/6reEBParHzQ/0.jpg" height="360" width="480" time="00:09:41.500"/>

 

$xml = simplexml_load_file('http://gdata.youtube.com/feeds/api/users/JREAMdesign/uploads');

echo "<pre>";
print_r($xml);

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/266659-xml-array-doesnt-show-entire-file/
Share on other sites

I think it's a known and reported bug that print_r() doesn't show everything, and especially namespaced stuff. Saw it last week or so.

 

If it's there in the XML then you can access it.

$xml->path->to->parent->children("media", true)->thumbnail

Thanks Req. Least it's not just me being silly then :)

 

That's a real pain though- can be quite time consuming trying to look through a huge xlm output.

 

Is there a better way to print out all of the xml file as an array? I looked at SimpleXMLIterator which might be useful. Any thoughts?

 

 

 

I think it's a known and reported bug that print_r() doesn't show everything, and especially namespaced stuff. Saw it last week or so.

 

If it's there in the XML then you can access it.

$xml->path->to->parent->children("media", true)->thumbnail

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.