Пример #1
0
<?php

namespace Xily;

header('Content-type: text/plain; charset=UTF-8');
include dirname(__FILE__) . '/../src/config.php';
include dirname(__FILE__) . '/../src/base.php';
include dirname(__FILE__) . '/../src/dict.php';
include dirname(__FILE__) . '/../src/xml.php';
include dirname(__FILE__) . '/../src/bean.php';
// First of, you can define custom bean directories for your bean classes. Xily will try to automatically include those classes when a certain bean is required.
Bean::$BEAN_DIRS = array(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'beans', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'beans');
// The following example uses Xily's <repeat/> bean to repeat a given data path and provide use each element
// as temporary dataset for all subsequent tags
$source = '<?xml version="1.0" encoding="UTF-8"?>
<html>
	<repeat source="#{.get(http://feeds.bbci.co.uk/news/technology/rss.xml)->xml->channel.item}">
		<div>
			<h3>#{title}</h3>
			<p>#{description}</p>
			<a href="#{link}">Read all</a>
		</div>
	</repeat>
</html>';
$xlyDoc = Bean::create($source);
echo $xlyDoc->run();
// Let's take a look at another exmple
class FormFrame extends Bean
{
    public function result($xmlData, $intLevel = 0)
    {