RE: [PHP] simplexml and xpath
| From: | Yoed Anis | Date: | Wed, 22 Sep 2004 03:10:21 +0000 |
| Subject: | RE: [PHP] simplexml and xpath | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-197507@lists.php.net to get a copy of this message | ||
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:matt@killermookie.org]
Sent: Tuesday, September 21, 2004 1:42 PM
To: php-general@lists.php.net
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