本文整理汇总了PHP中Tree::fromString方法的典型用法代码示例。如果您正苦于以下问题:PHP Tree::fromString方法的具体用法?PHP Tree::fromString怎么用?PHP Tree::fromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree::fromString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromString
/**
* Construct a XML-RPC message from a string
*
* <code>
* $msg= XmlRpcRequestMessage::fromString('<methodCall>...</methodCall>');
* </code>
*
* @param string string
* @return webservices.xmlrpc.XmlRpcMessage
*/
public static function fromString($string)
{
$msg = new XmlRpcRequestMessage();
$msg->tree = Tree::fromString($string);
// Set class and method members from XML structure
$target = $msg->tree->root()->nodeAt(0)->getContent();
list($msg->class, $msg->method) = explode('.', $target);
return $msg;
}
示例2: fromString
/**
* Construct a XML-RPC response message from a string
*
* <code>
* $msg= XmlRpcResponseMessage::fromString('<methodCall>...</methodCall>');
* </code>
*
* @param string string
* @return webservices.xmlrpc.XmlRpcResponse Message
*/
public static function fromString($string)
{
$msg = new self();
$msg->tree = Tree::fromString($string);
if (!$msg->tree->root()->hasChildren()) {
throw new FormatException('Response is not well formed');
}
// Set class and method members from XML structure
$target = $msg->tree->root()->nodeAt(0)->getContent();
@(list($msg->class, $msg->method) = explode('.', $target));
return $msg;
}
示例3: runTests
/**
* Run tests and return XML generated
*
* @param unittest.TestCase... tests
* @return xml.Tree the output
* @throws unittest.AssertionFailedError in case the generated XML is not well-formed
*/
protected function runTests()
{
foreach (func_get_args() as $test) {
$this->suite->addTest($test);
}
$this->suite->run();
try {
return Tree::fromString($this->out->getBytes());
} catch (XMLFormatException $e) {
$this->fail('XML generated is not well-formed: ' . $e->getMessage(), $this->out->getBytes(), NULL);
}
}
示例4: decode
/**
* Decode xml
*
* @param string xml
* @return mixed
*/
protected function decode($xml)
{
return create(new XmlRpcDecoder())->decode(Tree::fromString('<?xml version="1.0" encoding="utf-8"?><value>' . $xml . '</value>')->root());
}
示例5: fromString
/**
* Create a RDF from a string
*
* @param string str
* @return xml.rdf.RDFNewsfeed
*/
public static function fromString($str, $c = __CLASS__)
{
return parent::fromString($str, $c);
}
示例6: fromString
/**
* Create a new JNLP document from a string
*
* @param string str
* @return &com.sun.webstart.JnlpDocument
*/
public static function fromString($str)
{
if ($j = parent::fromString($str, __CLASS__)) {
$j->extract();
}
return $j;
}
示例7: setData
/**
* Set request's data and try to parse the request body (if available)
*
* @param string data The request's data
*/
public function setData($data)
{
parent::setData($data);
try {
$this->tree = Tree::fromString($data);
} catch (Exception $e) {
// Catch exception which occur when request body contains binary
// data (e.g. when PUTting files)
}
}
示例8: fromString
/**
* Create a WddxMessage object from an XML document.
*
* @param string string
* @return webservices.wddx.WddxMessage
*/
public static function fromString($string)
{
return parent::fromString($string, 'WddxMessage');
}
示例9: queryTreeWithEncoding
public function queryTreeWithEncoding()
{
$value = new String('value öäü', 'iso-8859-1');
$xpath = new XPath(Tree::fromString(sprintf('<?xml version="1.0" encoding="iso-8859-1"?>' . '<document><node>%s</node></document>', $value->getBytes('iso-8859-1'))));
$this->assertEquals($value, new String($xpath->query('string(/document/node)'), 'utf-8'));
}
示例10: fromNonXmlString
public function fromNonXmlString()
{
Tree::fromString('@@NO-XML-HERE@@');
}
示例11: fromString
/**
* Construct a document from a string
*
* @param string string
* @return xml.dom.Document
*/
public static function fromString($string, $class = __CLASS__)
{
return parent::fromString($string, $class);
}
示例12: unserialize
/**
* Unserializes xml data
*
* @param string xml
* @return mixed
*/
public function unserialize($xml)
{
$tree = Tree::fromString('<?xml version="1.0" encoding="utf-8"?><data>' . $xml . '</data>');
return $this->_recurse($tree->root);
}