$xmldata = file_get_contents("http://artcontext.org/wire/artcontextRSS2.0Feed.xml");
$itemArr = get_tag_contents($xmldata,"item");
foreach($itemArr as $key=>$code){
$pubDateArr = get_tag_contents($code,"pubDate");
$titleArr = get_tag_contents($code,"title");
$linkArr = get_tag_contents($code,"link");
$descriptionArr = get_tag_contents($code,"description");
print("
pubDate = ".$pubDateArr[0]."
");
print("title = ".$titleArr[0]."
");
print("link = ".$linkArr[0]."
");
print("description = ".$descriptionArr[0]."
");
}
function get_tag_contents($xmlcode,$tag) {
$i=0;
$offset=0;
$xmlcode = trim($xmlcode);
do{ #Step through each ocurrence of <$tag>...$tag> in the XML
#find the next start tag
$start_tag=strpos ($xmlcode,"<".$tag.">",$offset);
$offset = $start_tag;
#find the closing tag for the start tag you just found
$end_tag=strpos ($xmlcode,"".$tag.">",$offset);
$offset = $end_tag;
#split off <$tag>... as a string, leaving the $tag>
$our_tag = substr ($xmlcode,$start_tag,($end_tag-$start_tag));
$start_tag_length = strlen("<".$tag.">");
if (substr($our_tag,0,$start_tag_length)=="<".$tag.">"){
#strip off stray start tags from the beginning
$our_tag = substr ($our_tag,$start_tag_length);
}
$array_of_tags[$i] =$our_tag;
$i++;
}while(!(strpos($xmlcode,"<".$tag.">",$offset)===false));
return $array_of_tags;
}
?>