PHP
  Home arrow PHP arrow Converting XML Into a PHP Data Structure
Moblin
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
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? 
PHP

Converting XML Into a PHP Data Structure
By: Dante Lorenso
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 31
    2003-01-06

    Table of Contents:
  • Converting XML Into a PHP Data Structure
  • A Look at the XML File Structure
  • Using an Array as a Data Structure
  • Make PHP Do The Hard Work
  • Watching the XML Parsing Events: Callback Functions
  • Building the Array Tree
  • The Completed XMLToArray Class
  • How to Use the Class
  • 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
     
    Try It Free
     
    ADVERTISEMENT

    Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!

    Converting XML Into a PHP Data Structure


    (Page 1 of 9 )

    Dante explains how to convert data from XML to the more PHP friendly arrays and arrays in arrays so that it can be used easily in your code.In the last few years, XML has received great media attention, and most languages support the parsing and extraction of data from XML documents. Besides being a great three-letter anacronym to sprinkle on your résumé, XML is actually a useful data storage structure for PHP programmers.

    Before you begin to use XML, you must first determine if your project really needs what XML offers. There are alternative data storage formats like fixed-width column files, tab-delimited files, CSV files, and database tables, but these formats typically can only manage a simple grid of rows and columns of data.

    XML provides several additional benefits for programmers including:
    • data format abstraction,
    • simple document tag/data validation,
    • the ability to store data in a tree-like hierarchy,
    • platform independence,
    • ease of integration,
    • and more...

    ...but you already know that. What you want to do is use XML data inside your sparkling new web application. We'll explore one simple way to do this in the remainder of this article.

    More PHP Articles
    More By Dante Lorenso


     

    PHP ARTICLES

    - Making Usage Statistics in PHP
    - Installing PHP under Windows: Further Config...
    - File Version Management in PHP
    - Statistical View of Data in a Clustered Bar ...
    - Creating a Multi-File Upload Script in PHP
    - Executing Microsoft SQL Server Stored Proced...
    - Code 10x More Efficiently Using Data Access ...
    - A Few Tips for Speeding Up PHP Code
    - The Modular Web Page
    - Quick E-Commerce with PHP and PayPal
    - Regression Testing With JMeter
    - Building an Iterator with PHP
    - PHP Frontend to ImageMagick
    - Using PEAR's mimeDecode Module
    - Incoming Mail and PHP






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway