PHP Classes

Xml2Array: The class parse an XML file and load it

Recommend this page to a friend!
  Info   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 57%Total: 5,481 This week: 1All time: 456 This week: 560Down
Version License Categories
x2a 1.0GNU Lesser Genera...XML, Data types
Description 

Author

The class is meant to parse an XML file and load it into an array.

It uses the DOMXML extension functions to parse the XML tags, its attributes, the external entity and character data section.

The class also provides some functions to retrive part XML document structure into an array.

Picture of Andrioli Darvin
Name: Andrioli Darvin <contact>
Classes: 5 packages by
Country: Italy Italy
Age: 56
All time rank: 954 in Italy Italy
Week rank: 106 Down3 in Italy Italy Up

Details

CXml2Array version 1.1 27/02/2004 Description: ---------------------- The class is meant to parse an XML file and load it into an array. The module uses the DOMXML functions to parse the tag's values, the tag's attribute, the external entity and CDATA section. Also the class provides some functions to retrieve all or part of the array made from the XML file. Installation: ---------------------- PHP => 4.3.0 - I've test the class using PHP 4.3.0 and PHP 4.3.1. I think the class should work with PHP 4.2.x. The DOMXML extension enabled (see PHP manual how to enable it) Usage: ---------------------- // Here the code to run the class require 'CXml2Array.php'; $InName='test.xml'; if(!$TplDom = domxml_open_file(realpath($InName))) trigger_error('Error parsing the file ',E_USER_ERROR); $root = $TplDom->document_element(); $x=new CXml2Array($root); $ArrayXml=x->GetArray(); // if you want see the array contents, use $x->ArrayDump(); See test1.php to get more complete information about the usage visit my site http://www.andrioli.com/en/php.html ChangeLog: ---------------------- 1.1 - 27/2/2004 * Changed, now the child's tag are retrieved in the same order they are in the XML file * Changed, the text inside the tag are 'right-trimmed' in order to maintain the left spaces * New, new functions: GetText, GetTagName, EachChild, EachChildArray 1.0 - 15/12/2003 * First public release That's all. I hope it be useful. Darvin (darvin at andrioli dot com)

  Files folder image Files  
File Role Description
Plain text file CXml2Array.php Class Class source
Accessible without login Plain text file lgpl.txt Lic. License
Accessible without login Plain text file menu.ent Data Test data
Accessible without login Plain text file menu.left.ent Data test data
Accessible without login Plain text file menu.oriz.php.ent Data Test data
Accessible without login Plain text file readme.txt Doc. Class documentation
Accessible without login Plain text file test.xml Data Test data
Accessible without login Plain text file test1.php Example Test script

 Version Control Unique User Downloads Download Rankings  
 0%
Total:5,481
This week:1
All time:456
This week:560Down
 User Ratings  
 
 All time
Utility:72%StarStarStarStar
Consistency:75%StarStarStarStar
Documentation:62%StarStarStarStar
Examples:70%StarStarStarStar
Tests:-
Videos:-
Overall:57%StarStarStar
Rank:1693