/**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * 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);
     }
 }
 /**
  * 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());
 }
 /**
  * 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);
 }
 /**
  * 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;
 }
 /**
  * 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)
     }
 }
 /**
  * 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');
 }
Example #9
0
 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'));
 }
Example #10
0
 public function fromNonXmlString()
 {
     Tree::fromString('@@NO-XML-HERE@@');
 }
 /**
  * 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);
 }
Example #12
0
 /**
  * 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);
 }