本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
示例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();
}
示例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();
示例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);