當前位置: 首頁>>代碼示例>>PHP>>正文


PHP XMLWriter::writePi方法代碼示例

本文整理匯總了PHP中XMLWriter::writePi方法的典型用法代碼示例。如果您正苦於以下問題:PHP XMLWriter::writePi方法的具體用法?PHP XMLWriter::writePi怎麽用?PHP XMLWriter::writePi使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在XMLWriter的用法示例。


在下文中一共展示了XMLWriter::writePi方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: writeReaderImpl

 private function writeReaderImpl(XMLWriter $writer, XMLReader $reader)
 {
     switch ($reader->nodeType) {
         case XMLReader::ELEMENT:
             $writer->startElement($reader->name);
             if ($reader->moveToFirstAttribute()) {
                 do {
                     $writer->writeAttribute($reader->name, $reader->value);
                 } while ($reader->moveToNextAttribute());
                 $reader->moveToElement();
             }
             if ($reader->isEmptyElement) {
                 $writer->endElement();
             }
             break;
         case XMLReader::END_ELEMENT:
             $writer->endElement();
             break;
         case XMLReader::COMMENT:
             $writer->writeComment($reader->value);
             break;
         case XMLReader::SIGNIFICANT_WHITESPACE:
         case XMLReader::TEXT:
             $writer->text($reader->value);
             break;
         case XMLReader::PI:
             $writer->writePi($reader->name, $reader->value);
             break;
         default:
             XMLReaderNode::dump($reader);
     }
 }
開發者ID:hakre,項目名稱:xmlreaderiterator,代碼行數:32,代碼來源:XMLWritingIteration.php

示例2: getObject

 /**
  * @return \XMLWriter
  */
 public function getObject()
 {
     $xmlWriter = new \XMLWriter();
     $xmlWriter->openMemory();
     $xmlWriter->startDocument('1.0', 'UTF-8');
     $xmlWriter->setIndent(true);
     $xmlWriter->writePi('xml-stylesheet', 'type="text/xsl" href="./sitemap_css.xsl"');
     $xmlWriter->startElement('sitemapindex');
     $xmlWriter->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     return $xmlWriter;
 }
開發者ID:webowy,項目名稱:sitemap,代碼行數:14,代碼來源:Index.php

示例3: getObject

 /**
  * @return \XMLWriter
  */
 public function getObject()
 {
     $xmlWriter = new \XMLWriter();
     $xmlWriter->openMemory();
     $xmlWriter->startDocument('1.0', 'UTF-8');
     $xmlWriter->setIndent(true);
     $xmlWriter->writePi('xml-stylesheet', 'type="text/xsl" href="./sitemap_css.xsl"');
     $xmlWriter->startElement('urlset');
     $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $xmlWriter->writeAttribute('xmlns:image', 'http://www.google.com/schemas/sitemap-image/1.1');
     $xmlWriter->writeAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd');
     $xmlWriter->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     return $xmlWriter;
 }
開發者ID:webowy,項目名稱:sitemap,代碼行數:17,代碼來源:Sitemap.php

示例4: build

 /**
  * Creates an XML tree of the view data.
  * @param array $data Array of keys and values to be interpreted.
  * @param string $xslt <b>Optional</b>. Path of the XSL template.
  * @param boolean $iscompressed <b>Optional</b>. compresses the output if <b>TRUE</b>.
  */
 public function build($data, $xslt = null, $iscompressed = true)
 {
     $xml = new XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString(' ');
     $xml->startDocument('1.0', 'UTF-8');
     if (!empty($xslt)) {
         $xml->writePi('xml-stylesheet', "type=\"text/xsl\" href=\"{$xslt}\"");
     }
     $xml->startElement('root');
     $this->fromArray($xml, $data);
     $xml->endDocument();
     $contents_x = $xml->outputMemory();
     return !$iscompressed ? $contents_x : $this->xmlCompress($contents_x);
 }
開發者ID:phpcanvas,項目名稱:phpcanvas,代碼行數:22,代碼來源:xml_format.php

示例5: instruction

<?php

/* $Id$ */
/*
Libxml 2.6.24 and up adds a new line after a processing instruction (PI)
*/
$xw = new XMLWriter();
$xw->openMemory();
$xw->setIndent(TRUE);
$xw->startDocument("1.0", "UTF-8");
$xw->startElement('root');
$xw->writeAttribute('id', 'elem1');
$xw->startElement('elem1');
$xw->writeAttribute('attr1', 'first');
$xw->writeComment('start PI');
$xw->startElement('pi');
$xw->writePi('php', 'echo "hello world"; ');
$xw->endElement();
$xw->startElement('cdata');
$xw->startCdata();
$xw->text('<>&"');
$xw->endCdata();
$xw->endElement();
$xw->endElement();
$xw->endElement();
$xw->endDocument();
// Force to write and empty the buffer
$output = $xw->flush(true);
print $output;
開發者ID:lsqtongxin,項目名稱:hhvm,代碼行數:29,代碼來源:OO_009.php

示例6: createSitemapIndex

 /**
  * Writes Google sitemap index for generated sitemap files
  *
  * @param string $loc Accessible URL path of sitemaps
  * @param string|int $lastmod The date of last modification of sitemap. Unix timestamp or any English textual datetime description.
  */
 public function createSitemapIndex($loc, $lastmod = 'Today')
 {
     $this->endSitemap();
     $indexwriter = new \XMLWriter();
     $indexwriter->openURI($this->getPath() . $this->getFilename() . self::SEPERATOR . self::INDEX_SUFFIX . self::EXT);
     $indexwriter->startDocument('1.0', 'UTF-8');
     $indexwriter->setIndent(true);
     if ($this->getStyle() != '') {
         $indexwriter->writePi('xml-stylesheet', 'type="text/xsl" href="' . $this->getStyle() . '"');
     }
     $indexwriter->startElement('sitemapindex');
     $indexwriter->writeAttribute('xmlns', self::SCHEMA);
     for ($index = 0; $index < $this->getCurrentSitemap(); $index++) {
         $indexwriter->startElement('sitemap');
         $indexwriter->writeElement('loc', $loc . $this->getFilename() . ($index ? self::SEPERATOR . $index : '') . self::EXT);
         $indexwriter->writeElement('lastmod', $this->getLastModifiedDate($lastmod));
         $indexwriter->endElement();
     }
     $indexwriter->endElement();
     $indexwriter->endDocument();
 }
開發者ID:ericmuigai,項目名稱:sitemap-php,代碼行數:27,代碼來源:Sitemap.php

示例7: handlePostBack

    }
    function handlePostBack()
    {
        if (isset($_POST[$this->name])) {
            $this->value = $_POST[$this->name];
        }
    }
    function render($writer)
    {
        parent::render($writer);
        $writer->startElement('input');
        $writer->writeAttribute('type', 'text');
        $writer->writeAttribute('name', $this->name);
        $writer->writeAttribute('value', $this->value);
        $writer->endElement();
    }
}
//////////////////////////////////////
header('Content-type: text/xml');
$writer = new XMLWriter();
$writer->openURI('php://output');
$writer->startDocument('1.0');
$writer->setIndent(4);
$writer->writePi('xml-stylesheet', 'type="text/xsl" href="template.xsl"');
$controller = new PageVersionEditController();
if (isPostBack()) {
    $controller->handlePostBack();
}
$controller->view->render($writer);
$writer->endDocument();
$writer->flush();
開發者ID:ademirzanetti,項目名稱:labs,代碼行數:31,代碼來源:index.php

示例8: XMLWriter

* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB')) {
    exit;
}
$xml = new XMLWriter();
$xml->openMemory();
$xml->setIndent(true);
$xml->setIndentString("\t");
// The header
$xml->startDocument('1.0', 'UTF-8', 'yes');
$xml->writePi('xml-stylesheet', 'type="text/xsl" href="' . (!empty($preview) ? $phpbb_root_path . 'modx_files/' : '') . 'modx.prosilver.en.xsl"');
$xml->writeComment('NOTICE: Please open this file in your web browser. If presented with a security warning, you may safely tell it to allow the blocked content.');
$xml->writeComment('For security purposes, please check: http://www.phpbb.com/mods/ for the latest version of this MOD.\\nAlthough MODs are checked before being allowed in the MODs Database there is no guarantee that there are no security problems within the MOD.\\nNo support will be given for MODs not found within the MODs Database which can be found at http://www.phpbb.com/mods/');
// <mod>
$xml->startElement('mod');
$xml->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$xml->writeAttribute('xmlns', 'https://www.phpbb.com/mods/xml/' . MODX_LATEST);
// <header>
$xml->startElement('header');
// Need to reset the counters.
$parser->modx_reset();
// <meta>
// Start with the own meta tag
write_element('meta', '', array('name' => 'generator', 'content' => META), false, false);
while ($meta = $parser->get_modx_meta()) {
    write_element('meta', '', array('name' => $meta['name'], 'content' => $meta['content']), false, false);
開發者ID:andares-phpBB-Es,項目名稱:modx_creator_phpbb,代碼行數:31,代碼來源:create_modx.php


注:本文中的XMLWriter::writePi方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。