本文整理汇总了PHP中XMLWriter::outputMemory方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLWriter::outputMemory方法的具体用法?PHP XMLWriter::outputMemory怎么用?PHP XMLWriter::outputMemory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLWriter
的用法示例。
在下文中一共展示了XMLWriter::outputMemory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addPerfil
public function addPerfil($nome, $dataNascimento, $idade, $codUsuario)
{
# Instancia do objeto XMLWriter
$xml = new XMLWriter();
# Cria memoria para armazenar a saida
$xml->openMemory();
# Inicia o cabeçalho do documento XML
$xml->startDocument('1.0', 'iso-8859-1');
# Adiciona/Inicia um Elemento / Nó Pai <item>
$xml->startElement("perfil");
# Adiciona um Nó Filho <quantidade> e valor 8
$xml->writeElement("nome", $nome);
$xml->writeElement("datanascimento", $dataNascimento);
$xml->writeElement("idade", $idade);
$xml->writeElement("codusuario", $codUsuario);
# Finaliza o Nó Pai / Elemento <Item>
$xml->endElement();
# Configura a saida do conteúdo para o formato XML
header('Content-type: text/xml');
# Imprime os dados armazenados
print $xml->outputMemory(true);
# Salvando o arquivo em disco
# retorna erro se o header foi definido
# retorna erro se outputMemory já foi chamado
$file = fopen("cod" . $codUsuario . ".xml", "w+");
fwrite($file, $xml->outputMemory(true));
fclose($file);
}
示例2: testAmountIsWeightIsOmmittedIfFalse
public function testAmountIsWeightIsOmmittedIfFalse()
{
$this->record->setAmountIsWeight(false);
$this->gen->build();
$xml = $this->xmlWriter->outputMemory(true);
$this->assertNotTag(array('tag' => 'AMOUNT_IS_WEIGHT'), $xml, '', false);
}
示例3: filter
public function filter($value)
{
$this->_initReaderWriter();
$this->_reader->XML($value);
$this->_doXmlTrim();
$this->_writer->endDocument();
return $this->_writer->outputMemory();
}
示例4: serialize
/**
* @param array $ticket
* @return string
*/
public function serialize($ticket)
{
$this->buffer->writeRaw('<?xml version="1.0" encoding="utf-8"?>');
$this->buffer->startElement('ticket');
$this->generateTicket($ticket);
$this->buffer->endElement();
return $this->buffer->outputMemory();
}
示例5: export
/**
* Fetches the site with the given name and exports it into XML.
*
* @param array<Site> $sites
* @param boolean $tidy Whether to export formatted XML
* @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 string
*/
public function export(array $sites, $tidy = false, $nodeTypeFilter = null)
{
$this->xmlWriter = new \XMLWriter();
$this->xmlWriter->openMemory();
$this->xmlWriter->setIndent($tidy);
$this->exportSites($sites, $nodeTypeFilter);
return $this->xmlWriter->outputMemory(true);
}
示例6: finalize
public function finalize()
{
$this->writer->endElement();
$fragment = $this->contextNode->ownerDocument->createDocumentFragment();
$fragment->appendXML($this->writer->outputMemory());
$this->contextNode->parentNode->replaceChild($fragment, $this->contextNode);
$this->finalized = true;
}
示例7: export
/**
* Fetches the site with the given name and exports it into XML.
*
* @param array<Site> $sites
* @param boolean $tidy Whether to export formatted XML
* @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 string
*/
public function export(array $sites, $tidy = FALSE, $nodeTypeFilter = NULL)
{
$this->xmlWriter = new \XMLWriter();
$this->xmlWriter->openMemory();
$this->xmlWriter->setIndent($tidy);
$this->exportSites($sites, $nodeTypeFilter);
return $this->xmlWriter->outputMemory(TRUE);
}
示例8: toString
/**
* Get feed as XML string
*
* @return string
*/
public function toString()
{
if (!$this->output) {
$this->xml->endDocument();
$this->output = $this->xml->outputMemory(true);
}
// Remove empty elements
$this->output = preg_replace('#<[^>]*/>#', '', $this->output);
return $this->output;
}
示例9: write
/**
* Converts array with export data to XML format.
*
* @param array $array
*
* @return string
*/
public function write(array $array)
{
$this->xmlWriter->openMemory();
$this->xmlWriter->setIndent($this->formatOutput);
$this->xmlWriter->setIndentString(' ');
$this->xmlWriter->startDocument('1.0', 'UTF-8');
$this->fromArray($array);
$this->xmlWriter->endDocument();
return $this->xmlWriter->outputMemory();
}
示例10: testConvertsBooleanToString
public function testConvertsBooleanToString()
{
$this->record->setCalcBoilVolume(true);
$this->generator->build();
$xml = $this->xml->outputMemory(true);
$this->assertTag(array('tag' => 'CALC_BOIL_VOLUME', 'content' => 'TRUE'), $xml, '', false);
$this->record->setCalcBoilVolume(false);
$this->generator->build();
$xml = $this->xml->outputMemory(true);
$this->assertTag(array('tag' => 'CALC_BOIL_VOLUME', 'content' => 'FALSE'), $xml, '', false);
}
示例11: __toString
public function __toString()
{
$this->writer->openMemory();
$this->writer->startDocument($this->version, $this->encoding);
$this->writer->startElement($this->root);
foreach ($this->data as $key => $value) {
$this->writeElement($key, $value);
}
$this->writer->endElement();
$this->writer->endDocument();
return $this->writer->outputMemory(true);
}
示例12: to_xml
/**
* Convert the request data into XML.
*
* @since 4.3.0
* @return string
*/
protected function to_xml()
{
if (!empty($this->request_xml)) {
return $this->request_xml;
}
$this->xml = new XMLWriter();
// Create XML document in memory
$this->xml->openMemory();
// Set XML version & encoding
$this->xml->startDocument('1.0', 'UTF-8');
$request_data = $this->get_request_data();
SV_WC_Helper::array_to_xml($this->xml, $this->get_root_element(), $request_data[$this->get_root_element()]);
$this->xml->endDocument();
return $this->request_xml = $this->xml->outputMemory();
}
示例13: writeRequest
/**
* Write the service document in Atom format.
*
* @param Object &$dummy Dummy object
*
* @return string
*/
public function writeRequest(&$dummy)
{
$this->_xmlWriter = new \XMLWriter();
$this->_xmlWriter->openMemory();
$this->_xmlWriter->startElementNs(null, ODataConstants::ATOM_PUBLISHING_SERVICE_ELEMENT_NAME, ODataConstants::APP_NAMESPACE);
$this->_xmlWriter->writeAttributeNs(ODataConstants::XML_NAMESPACE_PREFIX, ODataConstants::XML_BASE_ATTRIBUTE_NAME, null, $this->_baseUri);
$this->_xmlWriter->writeAttributeNs(ODataConstants::XMLNS_NAMESPACE_PREFIX, self::ATOM_NAMESPACE_PREFIX, null, ODataConstants::ATOM_NAMESPACE);
$this->_xmlWriter->writeAttributeNs(ODataConstants::XMLNS_NAMESPACE_PREFIX, self::APP_NAMESPACE_PREFIX, null, ODataConstants::APP_NAMESPACE);
$this->_xmlWriter->startElement(ODataConstants::ATOM_PUBLISHING_WORKSPACE_ELEMNT_NAME);
$this->_xmlWriter->startElementNs(self::ATOM_NAMESPACE_PREFIX, ODataConstants::ATOM_TITLE_ELELMET_NAME, null);
$this->_xmlWriter->text(ODataConstants::ATOM_PUBLISHING_WORKSPACE_DEFAULT_VALUE);
$this->_xmlWriter->endElement();
foreach ($this->_metadataQueryproviderWrapper->getResourceSets() as $resourceSetWrapper) {
//start collection node
$this->_xmlWriter->startElement(ODataConstants::ATOM_PUBLISHING_COLLECTION_ELEMENT_NAME);
$this->_xmlWriter->writeAttribute(ODataConstants::ATOM_HREF_ATTRIBUTE_NAME, $resourceSetWrapper->getName());
//start title node
$this->_xmlWriter->startElementNs(self::ATOM_NAMESPACE_PREFIX, ODataConstants::ATOM_TITLE_ELELMET_NAME, null);
$this->_xmlWriter->text($resourceSetWrapper->getName());
//end title node
$this->_xmlWriter->endElement();
//end collection node
$this->_xmlWriter->endElement();
}
//End workspace and service nodes
$this->_xmlWriter->endElement();
$this->_xmlWriter->endElement();
$serviceDocumentInAtom = $this->_xmlWriter->outputMemory(true);
return $serviceDocumentInAtom;
}
示例14: XMLWriter
function impersonate_login($admin_user, $admin_pass, $site, $user)
{
//create a new xmlwriter object
$xml = new XMLWriter();
//using memory for string output
$xml->openMemory();
//set the indentation to true (if false all the xml will be written on one line)
$xml->setIndent(true);
//create the document tag, you can specify the version and encoding here
$xml->startDocument();
//Create an element
$xml->startElement("tsRequest");
$xml->startElement("credentials");
$xml->writeAttribute("name", $admin_user);
$xml->writeAttribute("password", $admin_pass);
$xml->startElement("site");
$xml->writeAttribute("contentUrl", strtoupper($site));
$xml->endElement();
//close contentUrl
$xml->startElement("user");
$xml->writeAttribute("id", $user);
$xml->endElement();
//close user
$xml->endElement();
//close credentials
$xml->endElement();
//close tsRequest
return $data_string = $xml->outputMemory();
}
示例15: creaXml
public function creaXml()
{
$writer = new XMLWriter();
//$writer->setIndent(true);
$csc = 1;
$writer->openMemory();
$writer->startDocument();
$writer->startElement("ROOT");
while (!$this->rs->EOF) {
$writer->startElement("registro");
$writer->startElement("CSC");
$writer->text($csc);
$writer->endElement();
for ($x = 0; $x < $this->rs->FieldCount(); $x++) {
$fld = $this->rs->FetchField($x);
$writer->startElement(strtoupper($fld->name));
$writer->text($this->rs->fields[strtoupper($fld->name)]);
$writer->endElement();
}
$writer->endElement();
$this->rs->MoveNext();
$csc++;
}
$writer->endElement();
$writer->endDocument();
$algo = $writer->outputMemory(true);
return $algo;
}