本文整理汇总了PHP中XMLWriter::flush方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLWriter::flush方法的具体用法?PHP XMLWriter::flush怎么用?PHP XMLWriter::flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLWriter
的用法示例。
在下文中一共展示了XMLWriter::flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: close
/**
* Close current writer and flush if needed.
*
* @return void
*/
public function close()
{
if ($this->xmlWriter) {
$this->xmlWriter->flush();
}
$this->xmlWriter = null;
}
示例2: finalize
public function finalize()
{
$this->xml->endElement();
//root element
$this->xml->endDocument();
$this->xml->flush();
return $this->filename;
}
示例3: end
public function end()
{
if (!$this->documentEnded) {
$this->xmlWriter->endDocument();
$this->xmlWriter->flush();
$this->documentEnded = true;
}
}
示例4: generateFileReport
/**
* Generate a partial report for a single processed file.
*
* Function should return TRUE if it printed or stored data about the file
* and FALSE if it ignored the file. Returning TRUE indicates that the file and
* its data should be counted in the grand totals.
*
* @param array $report Prepared report data.
* @param boolean $showSources Show sources?
* @param int $width Maximum allowed line width.
*
* @return boolean
*/
public function generateFileReport($report, $showSources = false, $width = 80)
{
$out = new XMLWriter();
$out->openMemory();
$out->setIndent(true);
if ($report['errors'] === 0 && $report['warnings'] === 0) {
// Nothing to print.
return false;
}
$out->startElement('file');
$out->writeAttribute('name', $report['filename']);
foreach ($report['messages'] as $line => $lineErrors) {
foreach ($lineErrors as $column => $colErrors) {
foreach ($colErrors as $error) {
$error['type'] = strtolower($error['type']);
if (PHP_CODESNIFFER_ENCODING !== 'utf-8') {
$error['message'] = iconv(PHP_CODESNIFFER_ENCODING, 'utf-8', $error['message']);
}
$out->startElement('error');
$out->writeAttribute('line', $line);
$out->writeAttribute('column', $column);
$out->writeAttribute('severity', $error['type']);
$out->writeAttribute('message', $error['message']);
$out->writeAttribute('source', $error['source']);
$out->endElement();
}
}
}
//end foreach
$out->endElement();
echo $out->flush();
return true;
}
示例5: Encode
public static function Encode($requestObject)
{
$soap = "";
try {
$writer = new XMLWriter();
$writer->openMemory();
$writer->startDocument();
$writer->setIndent(4);
$writer->startElement("soap:Envelope");
$writer->writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
$writer->writeAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
$writer->writeAttribute("xmlns:soap", "http://schemas.xmlsoap.org/soap/envelope/");
$writer->startElement("soap:Body");
$options = array(XML_SERIALIZER_OPTION_INDENT => ' ', XML_SERIALIZER_OPTION_LINEBREAKS => "\n", XML_SERIALIZER_OPTION_DEFAULT_TAG => '', XML_SERIALIZER_OPTION_TYPEHINTS => false, XML_SERIALIZER_OPTION_IGNORE_NULL => true, XML_SERIALIZER_OPTION_CLASSNAME_AS_TAGNAME => true);
$serializer = new XML_Serializer($options);
$result = $serializer->serialize($requestObject);
if ($result === true) {
$xml = $serializer->getSerializedData();
$xml = str_replace('<>', '', $xml);
$xml = str_replace('</>', '', $xml);
}
$writer->writeRaw($xml);
$writer->endElement();
$writer->endElement();
$writer->endDocument();
$soap = $writer->flush();
$soap = str_replace("<?xml version=\"1.0\"?>", "", $soap);
} catch (Exception $ex) {
throw new Exception("Error occurred while Soap encoding");
}
return $soap;
}
示例6: to_html
public function to_html($parent)
{
if (!$this->get_lang()) {
$this->log("to_html() no lang", 'error');
return null;
}
if (!$this->get_id()) {
$this->log("to_html() no id", 'error');
return null;
}
if (!$parent->get_request()->is_lang_ok($this->get_lang())) {
return null;
}
$w = new XMLWriter();
$w->openMemory();
$w->startElement('div');
$w->writeAttribute('class', 'subtitle');
$w->startElement('a');
$w->writeAttribute('class', 'subtitle_href');
$w->writeAttribute('href', $parent->get_prefix_url() . '/download-' . $this->get_id() . '.html');
$w->startElement('img');
$w->writeAttribute('class', 'subtitle_lang');
$w->writeAttribute('src', $parent->get_prefix_url() . '/images/flags/' . $this->get_lang() . '.gif');
$w->endElement();
$w->endElement();
$w->endElement();
return $w->flush();
}
示例7: endDocument
/**
* Returns the generated XML document or writes it to given filename. All open
* elements will be automatically closed before flushing.
*
* @param string $filename
* @return mixed
*/
public function endDocument($filename = '')
{
// mark document as done
$this->activeDocument = false;
// close all open tags
while ($this->openElements) {
$this->endElement();
}
if (empty($filename)) {
// return XML as string
return $this->xml->flush(true);
} else {
// write to file
file_put_contents($filename, $this->xml->flush(true));
}
}
示例8: xml_list
public static function xml_list()
{
$xw = new XMLWriter();
$xw->openMemory();
$xw->startDocument('1.0', 'UTF-8');
$xw->startElement('Albums');
$xw->setIndent(true);
foreach (ORM::factory('Album')->with('genre')->order_by('artist')->order_by('name')->find_all()->as_array() as $album) {
$xw->startElement('Album');
$xw->startElement('ID');
$xw->text($album->id);
$xw->endElement();
$xw->startElement('Artist');
$xw->text($album->artist);
$xw->endElement();
$xw->startElement('Name');
$xw->text($album->name);
$xw->endElement();
$xw->startElement('Genre');
$xw->text($album->genre->name);
$xw->endElement();
$xw->endElement();
// Album
}
$xw->endElement();
// Albums
$data = $xw->outputMemory(true);
$xw->flush();
unset($xw);
return $data;
}
示例9: to_html
public function to_html($parent)
{
$w = new XMLWriter();
$w->openMemory();
$w->startElement('div');
$w->writeAttribute('class', 'season');
$w->startElement('div');
$w->writeAttribute('class', 'season_name');
$w->text("Saison " . $this->get_num());
$w->endElement();
$w->startElement('div');
$w->writeAttribute('class', 'episode_container');
$str = "";
usort($this->episodes, 'wssub_cmp_num');
foreach ($this->episodes as $ep) {
if (!$ep->get_num()) {
$this->log("Bad ep with no number: " . $ep->to_string(), 'warn');
continue;
}
$str .= $ep->to_html($parent);
}
$w->writeRaw($str);
$w->endElement();
$w->endElement();
return $w->flush();
}
示例10: getData
/**
* Get written data
*
* @return $data
*/
public function getData() {
if ($this->_tempFileName == '') {
return $this->_xmlWriter->outputMemory(true);
} else {
$this->_xmlWriter->flush();
return file_get_contents($this->_tempFileName);
}
}
示例11: exportToFile
/**
* Fetches the site with the given name and exports it as XML into the given file.
*
* @param array<Site> $sites
* @param boolean $tidy Whether to export formatted XML
* @param string $pathAndFilename Path to where the export output should be saved to
* @param string $nodeTypeFilter Filter the node type of the nodes, allows complex expressions (e.g. "TYPO3.Neos:Page", "!TYPO3.Neos:Page,TYPO3.Neos:Text")
* @return void
*/
public function exportToFile(array $sites, $tidy = false, $pathAndFilename, $nodeTypeFilter = null)
{
$this->resourcesPath = Files::concatenatePaths(array(dirname($pathAndFilename), 'Resources'));
Files::createDirectoryRecursively($this->resourcesPath);
$this->xmlWriter = new \XMLWriter();
$this->xmlWriter->openUri($pathAndFilename);
$this->xmlWriter->setIndent($tidy);
$this->exportSites($sites, $nodeTypeFilter);
$this->xmlWriter->flush();
}
示例12: writeTo
/**
* @param string $resource
*/
private function writeTo($resource)
{
$this->writer->openURI($resource);
$this->writer->startDocument($this->version, $this->encoding);
$this->writer->setIndent(true);
$this->writer->setIndentString("\t");
$this->getRoot()->save($this->writer);
$this->writer->endDocument();
$this->writer->flush();
}
示例13: generate
/**
* generate export
*
* @return mixed filename/generated object/...
*/
public function generate()
{
$this->_writer = new XMLWriter();
$this->_writer->openURI('php://output');
$this->_writer->startDocument("1.0", "iso-8859-1");
$this->_writer->startElement("phonebooks");
$this->_writer->startElement("phonebook");
$this->_exportRecords();
$this->_writer->endDocument();
$this->_writer->flush();
}
示例14: createRequestXml
/** returns xml for hosted webservice "annul" request */
protected function createRequestXml()
{
$XMLWriter = new \XMLWriter();
$XMLWriter->openMemory();
$XMLWriter->setIndent(true);
$XMLWriter->startDocument("1.0", "UTF-8");
$XMLWriter->writeComment(\Svea\Helper::getLibraryAndPlatformPropertiesAsJson($this->config));
$XMLWriter->startElement($this->method);
$XMLWriter->writeElement("transactionid", $this->transactionId);
$XMLWriter->endElement();
$XMLWriter->endDocument();
return $XMLWriter->flush();
}
示例15: to_html
public function to_html($parent)
{
$w = new XMLWriter();
$w->openMemory();
$w->startElement('div');
$w->writeAttribute('class', 'log_message');
$w->startElement('div');
$w->writeAttribute('class', 'log_message_' . $this->type);
$w->writeRaw('<div class="log_class">' . $this->class . '</div>::<div class="log_msg">' . $this->msg . '</div>');
$w->endElement();
$w->endElement();
return $w->flush();
}