Yii Framework Forum: Installing and Using DOMIT! XML Parser - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Installing and Using DOMIT! XML Parser Rate Topic: -----

#1 User is offline   codezilla 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 14-July 09
  • Location:Thailand

Posted 14 July 2009 - 11:22 AM

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.

Quote

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:
<?php
Yii::import('your_path_to_domit');


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:
<?php
return array (
  // autoloading model and component classes
  'import'=>array(
      'application.vendors.*'
  )
);


To actually use DOMIT, you need to use the require_once() function in the classes that need it:
<?php
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:

<?php
$domit = new DOMIT_Document();
$path = '[your path to your .xml file]';
$success = $domit->loadXml($path);

if ($success)
{
  $docElement = $domit->documentElement;
  echo $docElement->toNormalizedString(true);
}
else
{
  echo 'Failed to load XML';
}


Don't you love Yii ? I love it!
0

#2 User is online   mbi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 608
  • Joined: 08-May 09

Posted 14 July 2009 - 06:52 PM

Why not use SimpleXML?
0

#3 User is offline   codezilla 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 14-July 09
  • Location:Thailand

Posted 14 July 2009 - 07:56 PM

Quote

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.

Cheers!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users