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

So I figured it out.

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

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

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

Reply via email to