本文整理汇总了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();
}
示例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;
}
示例3: flush
public function flush()
{
$this->cursor->endDocument();
return $this->cursor->flush();
}
示例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;
}
}
示例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;
}
}
示例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);
}