示例#1
0
 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
0
 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
0
文件: XmlTrim.php 项目: shevron/stoa
 public function filter($value)
 {
     $this->_initReaderWriter();
     $this->_reader->XML($value);
     $this->_doXmlTrim();
     $this->_writer->endDocument();
     return $this->_writer->outputMemory();
 }
 /**
  * @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();
 }
 /**
  * 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);
 }
 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;
 }
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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
0
 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
0
 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);
 }
 /**
  * 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();
 }
 /**
  * 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
0
 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
0
 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;
 }
示例#16
0
 /**
  * Creates the XML
  *
  * @return string BeerXML
  */
 public function render()
 {
     $this->xmlWriter->openMemory();
     $this->xmlWriter->startDocument('1.0', 'UTF-8');
     $this->xmlWriter->writeComment('Created with php-beerxml: https://github.com/georgeh/php-beerxml');
     list($setTag, $generator) = $this->getTagGeneratorForObject($this->records[0]);
     /** @var $generator Record */
     $generator->setXmlWriter($this->xmlWriter);
     $this->xmlWriter->startElement($setTag);
     foreach ($this->records as $record) {
         $generator->setRecord($record);
         $generator->build();
     }
     $this->xmlWriter->endElement();
     return $this->xmlWriter->outputMemory(true);
 }
 /**
  * Start Generating EDMX file.
  *
  * @return EDMX xml object.
  */
 public function generateEDMX()
 {
     $this->xmlWriter->startElementNS(ODataConnectorForMySQLConstants::EDMX_NAMESPACE_PREFIX, ODataConnectorForMySQLConstants::EDMX_ELEMENT, ODataConnectorForMySQLConstants::EDMX_NAMESPACE_1_0);
     $this->xmlWriter->writeAttribute(ODataConnectorForMySQLConstants::EDMX_VERSION, ODataConnectorForMySQLConstants::EDMX_VERSION_VALUE);
     $this->xmlWriter->endAttribute();
     $this->xmlWriter->startElementNS(ODataConnectorForMySQLConstants::EDMX_NAMESPACE_PREFIX, ODataConnectorForMySQLConstants::EDMX_DATASERVICES_ELEMENT, null);
     $this->xmlWriter->startElement(ODataConnectorForMySQLConstants::SCHEMA);
     $this->xmlWriter->writeAttribute(ODataConnectorForMySQLConstants::NAMESPACE1, $this->schema->namespace);
     $this->xmlWriter->writeAttributeNS(ODataConnectorForMySQLConstants::XMLNS_NAMESPACE_PREFIX, ODataConnectorForMySQLConstants::ODATA_NAMESPACE_PREFIX, null, ODataConnectorForMySQLConstants::ODATA_NAMESPACE);
     $this->xmlWriter->writeAttributeNS(ODataConnectorForMySQLConstants::XMLNS_NAMESPACE_PREFIX, ODataConnectorForMySQLConstants::ODATA_METADATA_NAMESPACE_PREFIX, null, ODataConnectorForMySQLConstants::ODATA_METADATA_NAMESPACE);
     $this->xmlWriter->writeAttribute(ODataConnectorForMySQLConstants::XMLNS_NAMESPACE_PREFIX, ODataConnectorForMySQLConstants::CSDL_VERSION_1_0);
     $this->xmlWriter->endAttribute();
     try {
         $this->writeEntityType();
         $this->writeAssociations();
         $this->writeEntityContainer();
         $this->writeEntityInfo();
         $this->writeMappingDetails();
     } catch (Exception $e) {
         ODataConnectorForMySQLException::createInternalServerError();
     }
     $this->xmlWriter->endElement();
     $this->xmlWriter->endElement();
     $this->xmlWriter->endElement();
     $this->xmlWriter->endElement();
     return $this->xmlWriter->outputMemory(true);
 }
示例#18
0
文件: feed.php 项目: karimo255/myblog
 public function index()
 {
     $writter = new \XMLWriter();
     $writter->openMemory();
     $writter->startDocument('1.0', 'UTF-8');
     $writter->setIndent(TRUE);
     $writter->startElement('rss');
     $writter->writeAttribute('version', '2.0');
     $writter->startElement('channel');
     //header
     $writter->writeElement('title', 'phpMint RSS');
     $writter->writeElement('link', 'mein LINK');
     $writter->writeElement('description', 'Ein PHP-Blog über PHP, jQuery, JavaScript und weiteren Technik-Themen.');
     //body
     foreach ($this->getPosts() as $key => $post) {
         $writter->startElement('item');
         $writter->writeElement('title', $post['title']);
         $writter->writeElement('pubDate', $post['datum']);
         $writter->writeElement('link', $post['slug']);
         $writter->writeElement('description', $post['preview']);
         $writter->endElement();
     }
     while ($writter->endElement() !== false) {
         continue;
     }
     $writter->endDocument();
     $test = $writter->outputMemory(TRUE);
     $loger = new \Loger('session');
     $loger->write($test);
     $this->response->addHeader('Content-type: text/xml; charset=UTF-8');
     $this->response->setOutput($test);
 }
示例#19
0
 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;
 }
示例#20
0
 /**
  * Returns the MARCXML collection footer
  *
  * This method produces an XML representation of a MARC record that
  * attempts to adhere to the MARCXML standard documented at
  * http://www.loc.gov/standards/marcxml/
  *
  * @return string           representation of MARC record in MARCXML format
  */
 function toXMLFooter()
 {
     $this->xmlwriter->endElement();
     // end collection
     $this->xmlwriter->endDocument();
     return $this->xmlwriter->outputMemory();
 }
 /**
  * Start Generating EDMX file.
  *
  * @return EDMX xml object.
  */
 public function saveConnectionParams()
 {
     $this->xmlWriter->startElement(ODataConnectorForMySQLConstants::CONNECTION_PARAMS);
     $this->xmlWriter->startElement(ODataConnectorForMySQLConstants::HOST);
     $this->xmlWriter->text($this->connectionParams['host']);
     $this->xmlWriter->endElement();
     $this->xmlWriter->startElement(ODataConnectorForMySQLConstants::PORT);
     if (isset($this->connectionParams['port'])) {
         $this->xmlWriter->text($this->connectionParams['port']);
     }
     $this->xmlWriter->endElement();
     $this->xmlWriter->startElement(ODataConnectorForMySQLConstants::DATABASE);
     $this->xmlWriter->text($this->connectionParams['dbname']);
     $this->xmlWriter->endElement();
     $this->xmlWriter->startElement(ODataConnectorForMySQLConstants::USER);
     $this->xmlWriter->text($this->connectionParams['user']);
     $this->xmlWriter->endElement();
     $this->xmlWriter->startElement(ODataConnectorForMySQLConstants::PASSWORD);
     $this->xmlWriter->text($this->connectionParams['password']);
     $this->xmlWriter->endElement();
     $this->xmlWriter->startElement(ODataConnectorForMySQLConstants::SERVICE);
     $this->xmlWriter->text($this->connectionParams['serviceName']);
     $this->xmlWriter->endElement();
     $this->xmlWriter->endElement();
     return $this->xmlWriter->outputMemory(true);
 }
示例#22
0
 public function Voice($MediaId)
 {
     $w = new \XMLWriter();
     $w->openMemory();
     $w->writeElement('MediaId', $MediaId);
     $this->add('Voice', $w->outputMemory(), true);
 }
示例#23
0
 public function getInfoByCode($user = '', $pass = '', $code = '')
 {
     //用户检查
     $action = new CodeInfo();
     if ($code) {
         $result = $action->getInfoByCodeFormMySystem($code);
     }
     $xw = new XMLWriter();
     $xw->openMemory();
     $xw->startDocument('1.0', 'gb2312');
     //版本與編碼
     $xw->startElement('packet');
     if ($result) {
         $xw->writeElement('result', 'true');
     } else {
         $xw->writeElement('result', 'false');
     }
     //查询条码失败
     $fields = array("code", "factoryNo", "goodsName", "spec", "current1", "voltage1", "direct", "constant", "grade", "madeIn", "madeDate");
     if ($result) {
         $xw->startElement('codeInfo');
         foreach ($result as $key => $value) {
             if (!is_bool(array_search($key, $fields))) {
                 $xw->writeElement($key, $value);
             }
         }
         $xw->endElement('codeInfo');
     }
     $xw->endElement('packet');
     return $xw->outputMemory(true);
 }
示例#24
0
 public function get()
 {
     $posts = Model::factory('Article')->where('status', '1')->order_by_desc('point')->limit(100)->find_many();
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->startDocument();
     $xml->startElement('urlset');
     foreach ($posts as $post) {
         $xml->startElement('url');
         $xml->startElement('loc');
         $xml->writeCdata($post->permalink());
         $xml->endElement();
         $xml->startElement('lastmod');
         $xml->writeCdata(date(DATE_ATOM, strtotime($post->modified_at ? $post->modified_at : $post->created_at)));
         $xml->endElement();
         $xml->startElement('changefreq');
         $xml->writeCdata('always');
         $xml->endElement();
         $xml->startElement('priority');
         $xml->writeCdata('1.0');
         $xml->endElement();
         $xml->endElement();
     }
     $xml->endElement();
     $this->data = $xml->outputMemory();
 }
示例#25
0
文件: XMLFio.php 项目: svobodni/web
 /**
  * Render XML
  *
  * @return string
  */
 public function getXml()
 {
     if ($this->content) {
         return $this->content;
     }
     $this->xml->endDocument();
     return $this->content = $this->xml->outputMemory();
 }
示例#26
0
 /**
  * @param string $source
  *
  * @return fDOMDocument
  *
  * @throws \TheSeer\fDOM\fDOMException
  */
 public function toXML($source)
 {
     $this->writer = new \XMLWriter();
     $this->writer->openMemory();
     $this->writer->setIndent(true);
     $this->writer->startDocument();
     $this->writer->startElement('source');
     $this->writer->writeAttribute('xmlns', 'http://xml.phpdox.net/token');
     $this->writer->startElement('line');
     $this->writer->writeAttribute('no', 1);
     $this->lastLine = 1;
     $tokens = token_get_all($source);
     foreach ($tokens as $pos => $tok) {
         if (is_string($tok)) {
             $line = 1;
             $step = 1;
             while (!is_array($tokens[$pos - $step])) {
                 $step++;
                 if ($pos - $step == -1) {
                     break;
                 }
             }
             if ($pos - $step != -1) {
                 $line = $tokens[$pos - $step][2];
                 $line += count(preg_split('/\\R+/', $tokens[$pos - $step][1])) - 1;
             }
             $token = array('name' => $this->map[$tok], 'value' => $tok, 'line' => $line);
             $this->addToken($token);
         } else {
             $line = $tok[2];
             $values = preg_split('/\\R+/Uu', $tok[1]);
             foreach ($values as $v) {
                 $token = array('name' => token_name($tok[0]), 'value' => $v, 'line' => $line);
                 $this->addToken($token);
                 $line++;
             }
         }
     }
     $this->writer->endElement();
     $this->writer->endElement();
     $this->writer->endDocument();
     $dom = new fDOMDocument();
     $dom->preserveWhiteSpace = false;
     $dom->loadXML($this->writer->outputMemory());
     return $dom;
 }
示例#27
0
 /**
  * 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);
 	}
 }
示例#28
0
function main()
{
    $x = new XMLWriter();
    $x->openMemory();
    $x->startDocument('1.0', null);
    $x->writeElement('root');
    $x->endDocument();
    var_dump($x->outputMemory(true));
}
示例#29
0
 public function testComplexRecordTypesAreSet()
 {
     $infusion = new MashStep();
     $infusion->setName('Infusion');
     $infusion->setType(MashStep::TYPE_INFUSION);
     $infusion->setStepTemp(68);
     $infusion->setStepTime(60);
     $infusion->setInfuseAmount(14);
     $this->record->addMashStep($infusion);
     $mashOut = new MashStep();
     $mashOut->setName('Mash Out');
     $infusion->setType(MashStep::TYPE_INFUSION);
     $infusion->setStepTemp(100);
     $infusion->setStepTime(10);
     $infusion->setInfuseAmount(4);
     $this->record->addMashStep($mashOut);
     $this->generator->build();
     $xml = $this->xml->outputMemory(true);
     $this->assertTag(array('tag' => 'MASH_STEPS', 'children' => array('count' => 2, 'only' => array('tag' => 'MASH_STEP'))), $xml, '', false);
 }
示例#30
0
 /**
  * Close and Output XML and stop script execution
  * @return void
  */
 public function output_xml()
 {
     $this->comment(sprintf("Estimated Execution Time Is: %s", preg_replace('/^0\\.(\\d+) (\\d+)$/', '\\2.\\1', microtime()) - START_TIME));
     $this->comments2xml($this->xmlw, $this->comments);
     $this->close_xml();
     $xml_out = $this->xmlw->outputMemory();
     $this->debug('---- Start XML Output ----');
     $this->debug(explode("\n", $xml_out));
     $this->debug('---- End XML Output ----');
     echo $xml_out;
     exit;
 }