<?php
$node = Craur::createFromJson(json_encode(array(
'feed' => array(
'@xmlns' => 'http://www.w3.org/2005/Atom',
'title' => array(
'@' => 'Example Feed',
'@lang' => 'en'
),
'link' => array(
array(
'@href' => 'http://example.org/feed/',
'@rel' => 'self'
),
array(
'@href' => 'http://example.org',
)
),
'author' => array(
'name' => 'John Doe',
'email' => 'hide@address.com'
)
)
)));
assert('http://www.w3.org/2005/Atom' == $node->get('hide@address.com'));
assert('Example Feed' == $node->get('feed.title'));
$titles = $node->get('feed.title[]');
assert('Example Feed' == $titles[0]);
foreach ($node->get('feed.link[]') as $link) {
assert(in_array($link->get('@href'), array('http://example.org/feed/', 'http://example.org')));
}
assert(strlen($node->toXmlString()));
assert(strlen($node->toJsonString()));
try
{
$author_string = $node->get('feed.author')->__toString();
assert(false);
}
catch (Exception $exception)
{
/*
* It should not be possible to convert the author to string,
* because it has no value.
*/
}