PHP Classes

Saxophone: PHP stream handler to search XML with XPATH

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2015-01-28 (1 year ago) RSS 2.0 feedStarStarStarStar 75%Total: 319 All time: 6,849 This week: 936Up
Version License PHP version Categories
saxophone 1.0.9GNU General Publi...5.0HTML, XML, Searching, Parsers
Description Author

This class is a PHP stream handler to search XML with XPATH or tag name.

It allows opening a XML document using fopen('sax:...').

The class can parses the XML document and search it using XPATH expressions to match the document data that is returned when the stream reading functions are called.

Innovation Award
PHP Programming Innovation award nominee
October 2013
Number 2

Prize: One downloadable copy of CodeLobster Professional
Some applications need to parse XML documents for extracting records of information that are stored in a certain structure.

This class can simplify the extraction of information from XML documents.

It uses the PHP streams support to open a virtual file with a name that includes the actual XML document file to parse, as well the format of the path of the XML elements to be extracting.

The XML elements path definition can be specified as a XPATH expression.

Using regular PHP file opening and reading functions it can return the XML elements that match the search expression.

Manuel Lemos
Picture of Juraj Puchký
  Performance   Level  
Name: Juraj Puchký <contact>
Classes: 5 packages by
Country: Czech Republic Czech Republic
Age: 34
All time rank: 172317 in Czech Republic Czech Republic
Week rank: 156 Up3 in Czech Republic Czech Republic Up
Innovation award
Innovation award
Nominee: 2x


  cccllxKXX    0oxkxX                                         
                   NdoldxX    KK0KK0O0d
                    kooclo0  0ldc;;coodkK
                     oxloo:X OkX0dc;cok0K                                      

 * @author Juraj Puchký - Devtech <>
 * @license GPLv3
 * @homepage
 * @copy (c) 2013 Juraj Puchký - Devtech

  Saxophone is simple stream xml parser with optional configuration support. You no need more than 1MB memory to process XML file.
  Is fast as possible and access interface is integrated into file stream support, that means you can access XML file from any where
  and process directly. Saxophone is licensed under GPLv3 any time you wish use in commercial application, kindly contact me and we will
  discuss commerce non exclusive developer license and conditions related with copyright rights.

How to use:

At first you have to include Saxophone.php class file.
Configure options global variable as well.

  $GLOBALS["xmlopt"] = array( 
     "encoding" => "utf-8", 
     "object" => "//*/SHOPITEM", 
     "type" => "XPATH",         // TAG,XPATH,TAGSLIST 
     "fields" => array( 
         "productName" => "//*/SHOPITEM/PRODUCT" 
Specify encoding
encoding - specify which encoding should be as target encoding for parsing XML file default is UTF-8.

Specify object
object - specifies tag name or xpath of object which encapsule required fields.

Types parser point of view
TAG      - Tags are separed and identified by TAG NAME only.
XPATH    - Tags are separed and identified by XPATH.
TAGSLIST - Result object has filled public supportedTags variable with array of exisiting tags.

Ignition of stream
  /- File handler
  |            /- Saxophone protocol
  |            |     /- global variable name of processed object accessor
  |            |     |     /- function name to post process parsed object
  |            |     |     |         /- function name to post process tag
  |            |     |     |         |          /- Url of XML File 
  |            |     |     |         |          |          /- global variable of saxophone parser options 
  |            |     |     |         |          |          |
 $fp = fopen("sax://xml;xprocess;xprocesstag;sample.xml;xmlopt","rb",true); 
 // Load fuel till end by 4096 bytes
 while(!feof($fp)) { fread($fp,4096);} 
 // Close fire
 // Mision completed we are on the orbit
  • Saxophone.png
  • Sample-1.01.png
  Files folder image Files  
File Role Description
Accessible without login Plain text file README.TXT Doc. Singing song untill im on the orbit
Accessible without login Plain text file sample.php Example Saxophone sample
Accessible without login Plain text file sample.txt Output Saxophone sample results
Accessible without login Plain text file sample.xml Data Saxophone sample data
Plain text file Saxophone-1.0.9.php Class Saxophone 1.0.9 class file
Plain text file Saxophone-1.1.0.php Class New version support of parse method

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:6,849
This week:936Up
 User Ratings  
 All time