Jump to content

Archived

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

annihilate

Get date from an XML file

Recommended Posts

Hello, I am trying to retrieve some data from an XML file and I am using some code from [a href=\"http://www.zend.com/zend/spotlight/code-gallery-wade6.php\" target=\"_blank\"]here[/a] to do it. The problem I am having is how to get the 'date uts' value, in the example below it is 1141249715.

The other values I can get ok using $_item['URL'] for example, and $_item['DATE'] gets me the Mar 1, 2006 bit.

[code]<track>
  <artist mbid="665e63e9-cf0c-49c7-b98d-0d42ff9c50de">The Jimi Hendrix Experience</artist>
  <name>In From The Storm</name>
  <mbid />
  <url>http://www.last.fm/music/The+Jimi+Hendrix+Experience/_/In+From+The+Storm</url>
  <date uts="1141249715">Mar 1, 2006, 21:48</date>
  </track>[/code]
The alternative I suppose would be to convert the Mar 1, 2006 bit into a timestamp, but seems overkill when there is already a timestamp there, I just can't work out how to access it!

Thanks

Share this post


Link to post
Share on other sites
Dude, I knew you could pick up chicks in an XML file!

Seriously though, after reading through that website it seems that the code posted there does not support extracting those tags. I haven't had to parse XML with PHP yet but I may investigate and see if I can be of more help later.

Share this post


Link to post
Share on other sites
Use the SimpleXML object/library. Zend should have some tutorials on that as well.

If the xml is well-formed, it will give you an easy way to extract whatever you want.

Share this post


Link to post
Share on other sites

×

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.