Miscellaneous
  Home arrow Miscellaneous arrow Page 4 - Processing XML with PHP
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MISCELLANEOUS

Processing XML with PHP
By: bluephoenix
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 2 stars2 stars2 stars2 stars2 stars / 11
    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

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    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


       · Is there any way to use this to parse external files, ie. RSS feeds from another...
       · This is output what i am getting.The following compiled languages were...
       · &lt;?php$compiled_langs = array();$interprt_langs = array();$flag =...
       · The program, as presented, does not work as presented. The problem, however, is not...
     

    MISCELLANEOUS ARTICLES

    - Using PHP to Stream MP3 Files and Prevent Il...
    - 10 Must Have Firefox Improvements
    - All About OpenOffice 3.0
    - Shell Script Writing
    - Loops in the UNIX Shell
    - The Test in the UNIX Shell
    - Data Streams and the UNIX Shell
    - Control Mechanisms of the UNIX Shell
    - Variables Within the UNIX Shell
    - The Shell and UNIX
    - In Detail: UNIX File Systems
    - Rights Management in UNIX
    - UNIX File Systems
    - The Terminal in UNIX
    - Operating Systems and UNIX





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek