For this simple query simple do a call to $item->date to get your time.
If the query is more complex in reality, do a foreach using xpath. See the
example on Xpath at www.php.net/simplexml

Yoed

-----Original Message-----
From: Matthew Sims [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 21, 2004 1:42 PM
To: [EMAIL PROTECTED]
Subject: [PHP] simplexml and xpath



So I've just recently fallen in love with simplexml. But from what I've
read, is it true that xpath doesn't really work properly?

I'm using an XML file that has a section like this:

<item>
<title>Title</title>
<link>Link</link>
<description>Desc</description> <dc:subject>Subject</dc:subject>
<dc:date>2004-09-20T18:15:00+00:00</dc:date>
</item>

My sample of my PHP code is:

<?php
$library = simplexml_load_file('file.rss');
foreach ($library->item as $item) {
  echo $item->xpath('dc:date');
}
?>

I just want to get the date. Am I doing xpath incorrectly or does xpath not
currently work properly in PHP5?

-- 
--Matthew Sims
--<http://killermookie.org>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to