This module is actually just a helper (for now, at least). But it is very handy when working with converting various data to XML in PHP. A few examples:
Simple example of the two different return values.
As DOMDocument:
<?php $doc = xml::toXML(array('root'=>array('fnupp'=>'dah'))); $doc->formatOutput = true; echo $doc->saveXML(); ?>
As DOMNode:
<?php $doc = new DOMDocument(); $container = $doc->appendChild($doc->createElement('root')); xml::toXML(array('fnupp'=>'dah'), $container); echo $doc->saveXML(); ?>
How the $container works:
xml::toXML(array('fnupp' => 'dah'))
will output:
<fnupp>dah</fnupp> xml::toXML(array('fnupp' => 'dah'), 'root')
will output:
<root> <fnupp>dah</fnupp> </root>
That was just a few examples, full documentation is within the helper PHP-file. That includes passing SQL and getting it back as XML directly, working with attributes etc.
All feedback is very welcome!
Hashes: #kohana xml module #kohana module #kohana #xml #php
This is a class that converts php (arrays,objects,variables) to xml:
ReplyDeletehttp://sourceforge.net/projects/domi/
Hope this helps you out.
Phillip Brown
DiscDev.com