PHP Classes

PHP XML Remove Spaces: Trim spaces from XML tag values

Recommend this page to a friend!
  Info   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 198 All time: 8,498 This week: 673Up
Version License PHP version Categories
nospace 1.0.0MIT/X Consortium ...5XML, PHP 5, Text processing


This is a very simple class that can remove spaces from XML tag values.

It takes a XML document as a SimpleXMLElement returned for instance by simplexml_load_file and traverses all the document tags.

The class trims the spaces around XML tag values and saves them back to the document.

Innovation Award
PHP Programming Innovation award nominee
November 2015
Number 13
Sometimes you need to process XML files that contain undesired spaces around the tag values.

This class can cleanup a XML document by trimming spaces around XML tag values.

Manuel Lemos
Picture of Thiago Augustus Oliveira
  Performance   Level  
Name: Thiago Augustus Oliveira <contact>
Classes: 1 package by
Country: Brazil Brazil
Age: 40
All time rank: 4146339 in Brazil Brazil
Week rank: 275 Up24 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 1x



Scrutinizer Code Quality Build Status Code Climate Build Status

Innovation Award

Remove both side spaces between words in a .xml file


$xml = simplexml_load_file( $xml_file );
var_dump( '<pre>', NoXMLSpace::noSpace($xml) );

  Files folder image Files  
File Role Description
Accessible without login Plain text file LICENSE Data Auxiliary data
Plain text file NoXMLSpace.class.php Class Class source
Accessible without login Plain text file Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:8,498
This week:673Up