本文整理匯總了PHP中Tree::root方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tree::root方法的具體用法?PHP Tree::root怎麽用?PHP Tree::root使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Tree
的用法示例。
在下文中一共展示了Tree::root方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: rootMember
public function rootMember()
{
with($t = new Tree('formresult'), $r = $t->root());
$this->assertClass($r, 'xml.Node');
$this->assertFalse($r->hasChildren());
$this->assertEmpty($r->getAttributes());
$this->assertEquals('formresult', $r->getName());
}
示例2: personTree
/**
* Returns an XML tree for use in further test cases
*
* @return xml.Tree
*/
protected function personTree()
{
$t = new Tree('person');
$t->root()->setAttribute('id', '1549');
$t->addChild(new Node('firstName', 'Timm'));
$t->addChild(new Node('lastName', 'Friebe'));
$t->addChild(new Node('location', 'Karlsruhe'));
$t->addChild(new Node('location', 'Germany'));
return $t;
}
示例3: marshal
/**
* Marshal an object to xml
*
* @param lang.Object instance
* @param xml.QName qname default NULL
* @return string xml
* @deprecated Use marshalTo() instead
*/
public static function marshal($instance, $qname = NULL)
{
$class = $instance->getClass();
// Create XML tree and root node. Use the information provided by the
// qname argument if existant, use the class` non-qualified (and
// lowercased) name otherwise.
$tree = new Tree();
if ($qname) {
$prefix = $qname->prefix ? $qname->prefix : $qname->localpart[0];
$tree->root()->setName($prefix . ':' . $qname->localpart);
$tree->root()->setAttribute('xmlns:' . $prefix, $qname->namespace);
} else {
if ($class->hasAnnotation('xmlns')) {
$tree->root()->setName($class->getSimpleName());
} else {
$tree->root()->setName(strtolower($class->getSimpleName()));
}
}
self::recurse($instance, $class, $tree->root(), array());
return $tree->getSource(INDENT_DEFAULT);
}
示例4: setXSLTree
public function setXSLTree()
{
$t = new Tree('xsl:stylesheet');
$t->root()->setAttribute('xmlns:xsl', 'http://www.w3.org/1999/XSL/Transform');
$this->processor->setXSLTree($t);
}