当前位置: 首页>>代码示例>>PHP>>正文


PHP SimpleXmlElement::asXml方法代码示例

本文整理汇总了PHP中SimpleXmlElement::asXml方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleXmlElement::asXml方法的具体用法?PHP SimpleXmlElement::asXml怎么用?PHP SimpleXmlElement::asXml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleXmlElement的用法示例。


在下文中一共展示了SimpleXmlElement::asXml方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test

/** @Assertions(2) */
function test()
{
    $x = new SimpleXmlElement();
    $a = $x->asXml();
    $b = $x->asXml(__FILE__);
    /** @type string|false */
    $a;
    /** @type boolean */
    $b;
}
开发者ID:walkeralencar,项目名称:ci-php-analyzer,代码行数:11,代码来源:method_interpreter_integration.php

示例2: fetch

 public function fetch($params)
 {
     $feed = null;
     //debug($params);
     if (isset($params['source'])) {
         $handle = fopen($params['source'], "rb");
         $feed = stream_get_contents($handle);
         fclose($handle);
     } else {
         echo 'A source is required.';
     }
     //debug($feed);
     $feed = new SimpleXmlElement($feed);
     if (isset($params['limit']) and $params['limit'] > 0) {
         // Not possible in SimpleXmlElement objects
     }
     //debug($feed); exit;
     if (isset($params['raw']) and $params['raw'] === true) {
         echo $feed->asXml();
     }
     if (isset($params['convert']) and $params['convert'] == 'json') {
         $feed = $this->convertToJson($feed->asXml());
     }
     //debug($feed);
     echo $feed;
 }
开发者ID:bjlbernal,项目名称:feeds,代码行数:26,代码来源:api.php

示例3: afterExercise

 /**
  * @param ExerciseCompleted $event
  */
 public function afterExercise(ExerciseCompleted $event)
 {
     $dom = new \DOMDocument('1.0');
     $dom->preserveWhitespace = false;
     $dom->formatOutput = true;
     $dom->loadXml($this->xml->asXml());
     $this->printer->write($dom->saveXML());
 }
开发者ID:jboffel,项目名称:behat-junit-formatter,代码行数:11,代码来源:JUnitFormatter.php

示例4: asXml

 public function asXml()
 {
     $xml = new SimpleXmlElement("<blueprint></blueprint>");
     $xml->addAttribute("key", $this->getKey());
     $xml->addAttribute("type", "form");
     $xml->addAttribute("name", $this->getName());
     foreach ($this->fields() as $field) {
         $f = $xml->addChild("field");
         $f->addAttribute("key", $field->getKey());
         $f->addChild("displayName", $field->getDisplayName());
         $f->addChild("format", $field->getFormat());
         $f->addChild("href", $field->getHref());
     }
     return $xml->asXml();
 }
开发者ID:benjaminhough,项目名称:blueprints-web-kit,代码行数:15,代码来源:ListBlueprint.php

示例5: serialize

 public function serialize($fmt, $app)
 {
     if (trim($fmt) === '') {
         $fmt = 'application/json';
     }
     $types = explode(',', $fmt);
     $count = count($types);
     $base = $app->request->getUrl() . $app->request->getRootUri();
     for ($i = 0; $i < $count; $i++) {
         if (strstr($types[$i], 'application/xml') !== false) {
             $app->response->headers->set('Content-Type', 'application/xml;odata.metadata=minimal');
             $xml = new SimpleXmlElement('<?xml version="1.0" encoding="utf-8"?><service/>');
             $xml->addAttribute('xmlns', 'http://www.w3.org/2007/app');
             $xml->addAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom');
             $xml->addAttribute('xmlns:m', 'http://docs.oasis-open.org/odata/ns/metadata');
             $xml->addAttribute('xml:base', $base);
             $xml->addAttribute('m:context', $base . '/$metadata');
             $workspace = $xml->addChild('workspace');
             $title = $workspace->addChild('atom:title', 'Default');
             $title->addAttribute('type', 'text');
             foreach ($this->collections as $collection) {
                 $col = $workspace->addChild('collection');
                 $col->addAttribute('href', $collection->getUrl());
                 $title = $col->addChild('atom:title', $collection->getName());
                 $title->addAttribute('type', 'text');
             }
             echo $xml->asXml();
             return;
         } else {
             if (strstr($types[$i], 'application/json') !== false) {
                 $app->response->headers->set('Content-Type', 'application/json;odata.metadata=minimal');
                 $resp = array();
                 $resp['@odata.context'] = $base . '/$metadata';
                 $collections = array();
                 foreach ($this->collections as $collection) {
                     array_push($collections, array('name' => $collection->getName(), 'kind' => 'EntitySet', 'url' => $collection->getUrl()));
                 }
                 $resp['value'] = $collections;
                 echo json_encode($resp);
                 return;
             }
         }
     }
     $app->response->setStatus(406);
     echo 'Unknown format for Service Doc: ' . $fmt;
     error_log($fmt);
 }
开发者ID:pboyd04,项目名称:SlimOData,代码行数:47,代码来源:class.ODataServiceDoc.php

示例6: asXml

 public function asXml()
 {
     $xml = new SimpleXmlElement("<blueprint></blueprint>");
     $xml->addAttribute("key", $this->getKey());
     $xml->addAttribute("type", "join");
     foreach ($this->fields() as $field) {
         $f = $xml->addChild("field");
         $f->addAttribute("key", $field->getKey());
         $f->addChild("displayName", $field->getDisplayName());
         $f->addChild("dataType", $field->getDataType());
         if ($field->isRequired()) {
             $f->addChild("required", "true");
         } else {
             $f->addChild("required", "false");
         }
         $f->addChild("minimum", $field->getMin());
         $f->addChild("maximum", $field->getMax());
         if ($field->isUnique()) {
             $f->addChild("unique", "true");
         } else {
             $f->addChild("unique", "false");
         }
         $f->addChild("example", $field->getExample());
         $f->addChild("foreignKey", $field->getForeignKey());
         $f->addChild("foreignValue", $field->getForeignValue());
         switch ($field->getDataType()) {
             case "string":
                 $f->addChild("encType", $field->getEncType());
                 $f->addChild("regexp", $field->getRegexp());
                 break;
             case "decimal":
                 $f->addChild("precision", $field->getPrecision());
                 break;
             case "enum":
                 $e = $f->addChild("enumOptions");
                 foreach ($field->getEnumOptions() as $option) {
                     $o = $e->addChild("option", $option);
                 }
                 break;
             case "text":
             case "binary":
                 $f->addChild("mimeType", $field->getMimeType());
                 break;
         }
     }
     return $xml->asXml();
 }
开发者ID:benjaminhough,项目名称:blueprints-web-kit,代码行数:47,代码来源:JoinBlueprint.php

示例7: xml

 /**
  * Get the help as an xml string.
  *
  * @param boolean $string
  *        	Return the SimpleXml object or a string. Defaults to true.
  * @return mixed. See $string
  */
 public function xml($string = true)
 {
     $parser = $this->_parser;
     $xml = new SimpleXmlElement('<shell></shell>');
     $xml->addChild('command', $parser->command());
     $xml->addChild('description', $parser->description());
     $xml->addChild('epilog', $parser->epilog());
     $subcommands = $xml->addChild('subcommands');
     foreach ($parser->subcommands() as $command) {
         $command->xml($subcommands);
     }
     $options = $xml->addChild('options');
     foreach ($parser->options() as $option) {
         $option->xml($options);
     }
     $arguments = $xml->addChild('arguments');
     foreach ($parser->arguments() as $argument) {
         $argument->xml($arguments);
     }
     return $string ? $xml->asXml() : $xml;
 }
开发者ID:julkar9,项目名称:gss,代码行数:28,代码来源:HelpFormatter.php

示例8: parse

 /**
  *	function parse()
  *	Gera um rss a partir de uma busca
  *	@version
  *	    0.1 03/06/2009  Método inicial
  *	    1.0 16/05/2010  Método refatorado completamente, renomeado, trocados
  *	        seus parâmetros, etc.
  *	
  *	@param $model O model a ser feita a busca
  *	@param $params Os parâmetros para a busca, será passado diretamente
  *	para o Model::all()
  */
 public function parse($model, $params = array())
 {
     //fazendo a busca
     $this->results = Loader::instance('Model', $model)->all($params);
     //pegando somente os campos
     $this->fields = !empty($this->results) ? array_keys(reset($this->results)) : array();
     //Limpando os campos "relations" que não existem em $this->allowedItems
     foreach ($this->config['relations'] as $key => $value) {
         if (!in_array($key, $this->allowedItems)) {
             unset($this->config['relations'][$key]);
         }
     }
     //Criando o cabeçalho
     $rss = new SimpleXmlElement('<?xml version="1.0" encoding="UTF-8" ?><rss xmlns:atom="http://www.w3.org/2005/Atom"></rss>');
     $rss->addAttribute('version', '2.0');
     $channel = $rss->addChild('channel');
     //verificando pelas tags permitidas, evitará a
     //inclusão de tags inválidas e poupará vários IFs.
     foreach ($this->allowedHeaders as $header) {
         if (!empty($this->config['headers'][$header])) {
             $channel->addChild($header, $this->format($this->config['headers'][$header], $header));
         }
     }
     //Procuro nos resultados
     foreach ($this->results as $row => $result) {
         $item = $channel->addChild("item");
         foreach ($this->config['relations'] as $key => $field) {
             $item->addChild($key, $this->format(String::insert($field, $result), $key));
             //                $item->addChild($key, $this->format($this->extract($field, $row), $key));
         }
     }
     return $rss->asXml();
 }
开发者ID:klawdyo,项目名称:spaghetti-lib,代码行数:45,代码来源:RssHelper.php

示例9: parseFormattedText

 function parseFormattedText($inputText, $bookName = "")
 {
     // Trim the carriage return characters in the input text
     $inputText = $this->trimCarriageReturns($inputText);
     // Get the line of $inputText
     $inputTextArray = explode("\n", $inputText);
     // Create root node
     $book = new SimpleXmlElement("<book></book>");
     $conjunctionAvailable = False;
     $currentChapter = "";
     $currentVerse = "";
     $currentClause = "";
     for ($i = 0; $i < count($inputTextArray); $i++) {
         $line = $inputTextArray[$i];
         $line = $this->trimSpaces($line);
         // Clause
         if (!$this->isLineNewChapterVerse($line) && !$this->isLineConjunction($line)) {
             $currentClause = $book->addChild("clause");
             //$currentClause->addChild("conj", "X");
             // Add text to the current clause
             $text = $currentClause->addChild("text", $line);
             // Set chapter and verse to the current chapter and verse
             $this->addChapterVerse($text, $currentChapter, $currentVerse);
         } else {
             if ($this->isLineConjunction($line)) {
                 // Add <conj> and </conj> tags into new clause
                 $currentClause = $book->addChild("clause");
                 // Add conj to current clause
                 $currentClause->addChild("conj", $line);
             } else {
                 // Store chapter, verse, and conj into variables
                 $chapterVerseConj = $this->getChapterVerseConj($line);
                 $chapter = $chapterVerseConj['chapter'];
                 $verse = $chapterVerseConj['verse'];
                 $conj = $chapterVerseConj['conj'];
                 // Set the chapter and verse to the current chapter and verse
                 $currentChapter = $chapter;
                 $currentVerse = $verse;
                 // Create a new clause for the conj
                 $currentClause = $book->addChild("clause");
                 // Add conj to current clause
                 $currentClause->addChild("conj", $conj);
                 $text = $currentClause->addChild("text", " ");
                 $this->addChapterVerse($text, $currentChapter, $currentVerse);
             }
         }
     }
     // After looping through the file, get the xml string
     $xml = $book->asXml();
     $pconjs = $this->getPconjList();
     return "{$pconjs}\n{$xml}";
 }
开发者ID:RandomlyKnighted,项目名称:discourse-analysis,代码行数:52,代码来源:parser.php

示例10: create_xml

 /**
  * @param $root
  * @param $type
  * @param $href
  * @param $content
  *
  * @return mixed
  */
 private function create_xml($root, $type, $href, $content)
 {
     global $client;
     $xml = new SimpleXmlElement('<' . $root . ' />');
     $xml->addAttribute('Type', $type);
     $xml->addAttribute('xmlns', 'http://www.veeam.com/ent/v1.0');
     $xml->addAttribute('xmlns:xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $xml->addAttribute('Href', $this->client->getBaseUrl() . "{$href}");
     $content = array_flip($content);
     array_walk_recursive($content, array($xml, 'addChild'));
     return $xml->asXml();
 }
开发者ID:haroldbuter,项目名称:veeam-cloudconnect,代码行数:20,代码来源:veeam.class.php

示例11: _buildRequest

 /**
 	Build an XML-RPC HTTP request for an XML-RPC call.
 
 	Parameters:
  		methodName - (string) name of the XML-RPC method to call
  		parameters - (array) parameters for the call
 
 	Returns:
 		(string) HTTP header + body
 */
 protected function _buildRequest($methodName, array $parameters = array())
 {
     if (!preg_match('~^[a-z0-9_.:/]+$~i', $methodName)) {
         throw new OpenReact_XmlRpc_Client_InvalidMethodNameException('The method name `%s` contains invalid characters.', array($methodName));
     }
     $methodCall = new SimpleXmlElement('<?xml version="1.0" encoding="' . self::ENCODING . '"?><methodCall></methodCall>');
     $methodCall->addChild('methodName', $methodName);
     $methodCall->addChild('params');
     foreach ($parameters as $value) {
         $param = $methodCall->params->addChild('param');
         $this->_encodeParam($param, $value);
     }
     $endpoint = parse_url($this->_endpoint);
     $body = $methodCall->asXml();
     $userAgent = 'OpenReact-XmlRpcClient/' . self::VERSION;
     if (isset($this->_userAgentSuffix)) {
         $userAgent .= ' ' . $this->_userAgentSuffix;
     }
     $headers = array('Host' => $endpoint['host'], 'User-Agent' => $userAgent, 'Content-Type' => 'text/xml;chartype=' . self::ENCODING, 'Content-Length' => strlen($body));
     $request = 'POST ' . $endpoint['path'] . ' HTTP/1.0' . "\r\n";
     foreach ($headers as $name => $value) {
         $request .= sprintf("%s: %s\r\n", $name, $value);
     }
     $request .= "\r\n" . $body;
     return $request;
 }
开发者ID:Bouwdie,项目名称:OpenReact_XmlRpc_Client,代码行数:36,代码来源:Client.php

示例12: build

 function build($args)
 {
     if (isset($args["Parts"])) {
         $parts = $args["Parts"];
         $xml = new SimpleXmlElement('<CompleteMultipartUpload></CompleteMultipartUpload>');
         if (is_array($parts)) {
             foreach ($parts as $part) {
                 $partXml = $xml->addChild("Part");
                 foreach ($part as $key => $value) {
                     if (in_array($key, Consts::$PartsElement)) {
                         $partXml->addChild($key, $value);
                     }
                 }
             }
         }
         return $xml->asXml();
     }
 }
开发者ID:leunico,项目名称:aliceBlog,代码行数:18,代码来源:Builders.php

示例13: __toString

 /**
  * Returns the object as XML.
  *
  * @return string The response as an XML string
  */
 public function __toString()
 {
     $xml = $this->element->asXml();
     return str_replace('<?xml version="1.0" ?>', '<?xml version="1.0" encoding="UTF-8" ?>', $xml);
 }
开发者ID:gecatalin,项目名称:telapi-php,代码行数:10,代码来源:InboundXML.php

示例14: parse

 /**
  * Processa todas as informações e devolve o Xml
  * 
  * @version
  *     0.1 19/05/2010
  *         Inicial
  *     0.2 02/11/2010
  *         Modificado o uso para SimpleXml
  *  
  * @return string Xml contendo o sitemap já pronto
  */
 public function parse()
 {
     //Criando o cabeçalho
     $sitemap = new SimpleXmlElement('<?xml version="1.0" encoding="UTF-8" ?><urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>');
     //parseando as páginas
     foreach ($this->output as $items) {
         $url = $sitemap->addChild('url');
         foreach ($items as $key => $part) {
             $url->addChild($key, $part);
         }
     }
     return $sitemap->asXml();
 }
开发者ID:klawdyo,项目名称:spaghettiphp,代码行数:24,代码来源:SitemapHelper.php


注:本文中的SimpleXmlElement::asXml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。