Code: Select all
<?php
$r ="http://twitter.com/statuses/user_timeline/deostroll.xml";
$res = file_get_contents( $r );
$d = new DOMDocument();
$d->loadXML($res);
if ($d == null)
{
echo('document is null');
}
$e = $d->documentElement;
if ($e == null)
{
echo('element is null');
}
foreach ( $e->childNodes as $status )
{
#$created_at = $status->getElementsByTagName('created_at')->item(0);
echo print_r($status);
}
?>
In the above code if you see the commented line I get an error while trying to execute $status->getElementsByTagName(). Later I find out $status aint of type DOMNode. Its DOMText. I need to find an element under each status node, and print data which comes inside of it...something like:
Code: Select all
<status>
<created_at>10/12/2007 14:53:25</created_at><!--trrying to print value inside this tag -->
.
.
.
</status>