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


PHP XmlWriter::endDocument方法代码示例

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


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

示例1: close

 public function close()
 {
     for ($i = 0; $i < $this->openElements; $i++) {
         $this->writer->endElement();
     }
     $this->openElements = 0;
     $this->writer->endDocument();
 }
开发者ID:JoshBour,项目名称:karolina,代码行数:8,代码来源:SitemapXmlParser.php

示例2: outputSitemap

 public function outputSitemap(Kwf_Component_Data $page)
 {
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->startDocument('1.0', 'UTF-8');
     $xml->startElement('urlset');
     $xml->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     foreach (array_unique($this->_getSitemap($page)) as $url) {
         $xml->startElement('url');
         $xml->writeElement('loc', $url);
         $xml->endElement();
     }
     $xml->endElement();
     $xml->endDocument();
     header('Content-Type: text/xml; charset=utf-8');
     echo $xml->outputMemory(true);
     exit;
 }
开发者ID:nsams,项目名称:koala-framework,代码行数:18,代码来源:Sitemap.php

示例3: flush

 public function flush()
 {
     $this->cursor->endDocument();
     return $this->cursor->flush();
 }
开发者ID:GromNaN,项目名称:oxm,代码行数:5,代码来源:WriterHelper.php

示例4: generate

 /**
  * Generates the XML output and saves it to a file or returns it as a string
  *
  * @return null|int Returns the number of bytes written to a local file or false on failure
  */
 protected function generate()
 {
     $w = new \XmlWriter();
     $w->openMemory();
     $w->setIndent(true);
     $w->setIndentString("    ");
     $w->startDocument('1.0', 'utf-8');
     $w->startElement($this->rootname);
     $row = $this->getRow();
     $keys = array_keys($row);
     foreach ($keys as $key) {
         $this->isValidName($key);
     }
     do {
         $w->startElement($this->rowname);
         foreach ($row as $key => $value) {
             if ($this->suppress && in_array($key, $this->suppress)) {
                 continue;
             }
             if ($this->hasChildren && in_array($key, $this->hasChildren)) {
                 $stripped = $this->stripHtml($value);
                 $w->startElement($key);
                 foreach ($stripped as $para) {
                     $w->writeElement('p', $para);
                 }
                 $w->endElement();
             } else {
                 $w->writeElement($key, $value);
             }
         }
         $w->endElement();
     } while ($row = $this->getRow());
     $w->endElement();
     $w->endDocument();
     $this->xml = $w->outputMemory();
     // write to file
     if (isset($this->filename) && $this->local) {
         $success = file_put_contents($this->filename, $this->xml);
         return $success;
     } elseif (isset($this->filename) && $this->download) {
         $this->outputHeaders();
         file_put_contents('php://output', $this->xml);
         exit;
     }
 }
开发者ID:sbogdanov108,项目名称:db_to_text,代码行数:50,代码来源:Xml.php

示例5: generate

 /**
  * Generates the XML output and saves it to a file or returns it as a string
  *
  * @return null|int Returns the number of bytes written to a local file or false on failure
  */
 protected function generate()
 {
     $w = new \XmlWriter();
     $w->openMemory();
     $w->setIndent(true);
     $w->setIndentString("    ");
     $w->startDocument('1.0', 'utf-8');
     $w->startElement($this->rootname);
     while ($object = $this->getRow()) {
         // Start a new row for each object
         $w->startElement($this->rowname);
         foreach ($object as $key => $value) {
             if ($this->suppress && in_array($key, $this->suppress)) {
                 continue;
             }
             $this->isValidName($key);
             // Check if the key contains another object
             if (is_object($value)) {
                 // Start parent element containing rows of each object
                 $w->startElement($key . "s");
                 // $value is an array of objects
                 foreach ($value as $obj) {
                     $w->startElement($key);
                     foreach ($obj as $field => $val) {
                         $this->isValidName($key);
                         $w->writeElement($field, $val);
                     }
                     $w->endElement();
                 }
                 $w->endElement();
             } else {
                 // Write each object's property->value as <key>value</key>
                 if ($this->hasChildren && in_array($key, $this->hasChildren)) {
                     $stripped = $this->stripHtml($value);
                     $w->startElement($key);
                     foreach ($stripped as $para) {
                         $w->writeElement('p', $para);
                     }
                     $w->endElement();
                 } else {
                     $w->writeElement($key, $value);
                 }
             }
         }
         $w->endElement();
     }
     $w->endElement();
     $w->endDocument();
     $this->xml = $w->outputMemory();
     // write to file
     if (isset($this->filename) && $this->local) {
         $success = file_put_contents($this->filename, $this->xml);
         return $success;
     } elseif (isset($this->filename) && $this->download) {
         $this->outputHeaders();
         file_put_contents('php://output', $this->xml);
         exit;
     }
 }
开发者ID:Hemant-Mann,项目名称:PHPExport,代码行数:64,代码来源:Xml.php

示例6: flush

 /**
  * The parameter is merely to comply with PHP's notion that I am
  * overriding the parent's flush, so I should provide the same
  * signature. Nor am I not, but, even if I was, PHP should allow
  * different signatures, i.e., enable both methods to be called...
  *
  * @see XMLWriter::flush()
  */
 public function flush($empty = true)
 {
     parent::endDocument();
     return parent::flush($empty);
 }
开发者ID:rasismeiro,项目名称:cintient,代码行数:13,代码来源:XmlDoc.php


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