Reference: PHP enthusiast This example in this example is located in http://www.slashdot.org/slashdot.xml This PHP file read, the XML file content is below the content of the PHP file, and the PHP file and Slashdot.xml is placed in the same folder php $ open_tags = array ('story' => '
$ close_tags = array ('story' => ' story>', 'title' => ' title>', 'URL', 'Author' => ' author' > ');?>?>
PHP // The following is the definition function to extract the data:
// Processing Start Tag Attribute Independence // $ Attrs is a multi-dimensional array, the key value is the value of the value of this property Function StartElement ($ PARSER, $ Name, $ attrs = ') {global $ open_tags, $ { Temp, $ current_tag; $ current_tag = $ name; if ($ format = $ open_tags [$ name]) {switch ($ name) {case 'story': echo 'new story:'; break; default: Break;} }
// $ current_tag tells us that the tag that is being processed, then we will then use // // when you encounter story> tags in the CharacterData function, we know all of the temporary variables to Flush next Mark Function endElement ($ Parser $ Name, $ attrs = '') {Global $ close_tags, $ TEMP, $ CURRENT_TAG; IF ($ format = $ close_tags [$ name]) {switch ($ name) {case 'story': return_page ($ TEMP) $ TEMP = ''; Break; default: Break;}}}
// Transfer to this function data ///, for example,