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
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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.