Jump to content


Photo

Get date from an XML file


  • Please log in to reply
2 replies to this topic

#1 annihilate

annihilate
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts
  • LocationUK

Posted 05 March 2006 - 01:47 AM

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.

<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>
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
Personal site: NewEnigma  |  Java and JSF Discussion

#2 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 05 March 2006 - 02:42 AM

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.

#3 jajtiii

jajtiii
  • Members
  • PipPipPip
  • Advanced Member
  • 43 posts

Posted 05 March 2006 - 04:17 AM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users