本文整理汇总了PHP中Tree::getSource方法的典型用法代码示例。如果您正苦于以下问题:PHP Tree::getSource方法的具体用法?PHP Tree::getSource怎么用?PHP Tree::getSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree::getSource方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: serialize
/**
* Serialize
*
* @param var value
* @return string
*/
public function serialize($payload)
{
$t = new Tree();
$t->setEncoding('UTF-8');
if ($payload instanceof Payload) {
$root = isset($payload->properties['name']) ? $payload->properties['name'] : 'root';
$payload = $payload->value;
} else {
$root = 'root';
}
if ($payload instanceof Generic || is_array($payload)) {
$t->root = Node::fromArray($this->convert($payload), $root);
} else {
$t->root = new Node($root, $this->convert($payload));
}
return $t->getDeclaration() . "\n" . $t->getSource(INDENT_NONE);
}
示例2: setXMLTree
/**
* Set XML from a tree
*
* @param xml.Tree xml
*/
public function setXMLTree(Tree $xml)
{
libxml_get_last_error() && libxml_clear_errors();
$this->document = new DOMDocument();
$this->document->loadXML($xml->getDeclaration() . $xml->getSource(INDENT_NONE));
$this->_checkErrors($xml);
}
示例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: performance
public function performance()
{
$s = microtime(TRUE);
$t = new Tree();
for ($i = 0; $i < 100; $i++) {
$c = $t->addChild(new Node('child', NULL, array('id' => $i)));
for ($j = 0; $j < 100; $j++) {
$c->addChild(new Node('elements', str_repeat('x', $j)));
}
}
$l = strlen($t->getSource(INDENT_NONE));
printf('%d bytes, %.3f seconds', $l, microtime(TRUE) - $s);
}
示例5: getSource
/**
* Returns the full XML source of the 'dia' diagram
*
* @return string XML representation of the DIAgramm
*/
public function getSource($indent = INDENT_DEFAULT)
{
$Node = $this->getNode();
$Tree = new Tree();
$Tree->root = $Node;
return $Tree->getDeclaration() . "\n" . $Tree->getSource($indent);
}