本文整理汇总了PHP中Tree::getDeclaration方法的典型用法代码示例。如果您正苦于以下问题:PHP Tree::getDeclaration方法的具体用法?PHP Tree::getDeclaration怎么用?PHP Tree::getDeclaration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree::getDeclaration方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}