############################################# # This is rdf-parse.inc, which parses RDF # # files and outputs links to their ITEMs # # # # Optionally, it can also print HTML for # # the IMAGE and CHANNEL bits of the XML. # # Just uncomment those lines in endElement # # and put in appropriate HTML. # # # # Usage: # # parseRDF("filename") # # note: "filename" can be a URL # # # # Requires: # # PHP 4 compiled with "--use-xml" # # # # Creates: # # Global variables $_depth, $_tags, and # # $_item # # # # History: # # v0.6b - fr3nd notified me of a party- # # crashing feature of expat that # # didn't parse stuff like & # # properly. Fixed. Also fixed # # initArray(), which didn't # # do anything at all. # # v0.61b- fixed a missing ) on line 46 # ############################################# $_item = array(); $_depth = array(); $_tags = array( "dummy" ); # "dummy" prevents unecessary subtraction in the $_depth indexes function initArray() { global $_item; $_item = array ("TITLE"=>"", "LINK"=>"", "DESCRIPTION"=>"", "URL"=>"" ); } function startElement($parser, $name, $attrs) { global $_depth, $_tags, $_item; if ( ($name=="ITEM")||($name=="CHANNEL")||($name=="IMAGE") ) { initArray(); } $_depth[$parser]++; array_push($_tags, $name); } function endElement($parser, $name) { global $_depth, $_tags, $_item; array_pop($_tags); $_depth[$parser]--; switch ($name) { case "ITEM": echo "
$_item[TITLE]
$_item[DESCRIPTION]