Installing and Using DOMIT! XML Parser

For those who use DOMIT, here is the how to install it and to use it in Yii:

Download DOMIT from: http://sourceforge.n…omit-xmlparser/

Create a folder name vendors in your protected folder.


protected/ vendors

Extract the downloaded .tar.gz, or .zip archived of DOMIT! into protected/vendors folder. So now it will be protected/vendors/domit

Loading DOMIT:

You can load it on the classes(either your controllers, models, or components) that use it by using:



Or, you can load it in the configuration file protected/config/main.php, then you won’t need to write Yii::import(‘your_path_to_domit’) everytime you want to import DOMIT! because it is now autoloaded:


return array (

   // autoloading model and component classes	





To actually use DOMIT, you need to use the require_once() function in the classes that need it:


require_once('yourpath_to_domit/xml_domit_include.php'); // to use domit lite instead, use xml_domit_lite_include.php

You can start to instantiate the DOMIT_Document:


$domit = new DOMIT_Document();

$path = '[your path to your .xml file]';

$success = $domit->loadXml($path);

if ($success)


   $docElement = $domit->documentElement;

   echo $docElement->toNormalizedString(true);




   echo 'Failed to load XML';


Don't you love Yii ? I love it!

Why not use SimpleXML?


Why not use SimpleXML?

Well, of course why not use SimpleXML ? At anytime you can use SimpleXML.

This is not for a debate though. I just show some folks who have written code to write and read XML file with DOMIT using the old application library from the programmers before them.