Miscellaneous

  Home arrow Miscellaneous arrow Page 4 - Processing XML with PHP
MISCELLANEOUS

Processing XML with PHP
By: bluephoenix
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 15
    2003-10-12

    Table of Contents:
  • Processing XML with PHP
  • Create the Parser Object
  • Configure the Parser
  • Define the Callbacks
  • Read the XML Document
  • Conclusion

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Processing XML with PHP - Define the Callbacks


    (Page 4 of 6 )

    The processor will make use of callback functions to handle the opening tags, closing tags and content of the XML document. These functions are identified to the processor though use of xml_set_element_handler and xml_set_character_data_handler functions. Each accepts the parser handle and the names of the callback functions we'll need to write later.

    <?php
    function opening_element($parser$element$attributes) {
      
    /* opening XML element callback function */

    }

    function 
    closing_element($parser$element) {
      
    /* closing XML element callback function */

    }

    function 
    character_data($parser$data) {
      
    /* callback function for character data */

    }

    xml_set_element_handler($parser"opening_element""closing_element");
    xml_set_character_data_handler($parser"character_data");
    ?>

    Note that the callback functions receive arguments: the opening XML element callback function accepts the parser handle, the current element and the element's attributes. The closing element callback function accepts the parser handle and the current element. The callback function responsible for handling the character data accepts the parser handle as well as the data. The attributes accepted by the opening element function is an array, of which the attribute names act as keys.

    More Miscellaneous Articles
    More By bluephoenix

    blog comments powered by Disqus

    MISCELLANEOUS ARTICLES

    - Oracle Database XE: Indexes and Sequences
    - Modifying Tables in Oracle Database XE
    - Oracle Database XE: Tables and Constraints
    - More on Oracle Databases and Datatypes
    - Oracle Database XE Datatypes: Datetime and L...
    - Oracle Database XE Datatypes: Character and ...
    - From Databases to Datatypes
    - Firefox 3.6.6 Released with Improved Plug-in...
    - Attention Bloggers: WordPress 3.0 Now Releas...
    - Reflection in PHP 5
    - Inheritance and Other Advanced OOP Features
    - Advanced OOP Features
    - Linux from Scratch V.6.6 Review
    - Linux Gaining in Strength
    - Install Slackware on Your Old PC


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap