本文整理汇总了PHP中XMLWriter::endElement方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLWriter::endElement方法的具体用法?PHP XMLWriter::endElement怎么用?PHP XMLWriter::endElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLWriter
的用法示例。
在下文中一共展示了XMLWriter::endElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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();
}
示例3: index
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);
}
示例4: writeCommon
private function writeCommon(\XMLWriter $writer, Common $common)
{
if ($common->getAuthor()) {
$writer->startElement('itunes:author');
$writer->writeCdata($common->getAuthor());
$writer->endElement();
}
if ($common->getSummary()) {
$writer->startElement('itunes:summary');
$writer->writeCdata($common->getSummary());
$writer->endElement();
}
if ($common->getBlock()) {
$writer->writeElement('itunes:block', 'Yes');
}
if ($common->getImage()) {
$writer->startElement('itunes:image');
$writer->writeAttribute('href', $common->getImage());
$writer->endElement();
}
$writer->writeElement('itunes:explicit', true === $common->getExplicit() ? 'Yes' : 'No');
if ($common->getSubtitle()) {
$writer->startElement('itunes:subtitle');
$writer->writeCdata($common->getSubtitle());
$writer->endElement();
}
}
示例5: generateTicket
/**
* @param $ticket
*/
private function generateTicket($ticket)
{
$this->ticket = $ticket;
$this->writeSingleElement('key');
$this->writeSingleElement('reporter');
$this->writeSingleElement('issueType');
$this->writeImagePathElement();
$this->writeSingleElement('sprint');
$this->writeSingleElement('summary');
$this->writeSingleElement('devTeam');
$this->writeSingleElement('hasSubTasks');
$this->writeSingleElement('storyPoints');
if (isset($this->ticket['epicData'])) {
$this->buffer->startElement('epic');
$this->buffer->writeElement('key', $this->ticket['epicData']['key']);
$this->buffer->writeElement('summary', $this->ticket['epicData']['summary']);
$this->buffer->endElement();
}
if (isset($this->ticket['parentData'])) {
$this->buffer->startElement('parent');
$this->buffer->writeElement('key', $this->ticket['epicData']['key']);
$this->buffer->writeElement('summary', $this->ticket['epicData']['summary']);
$this->buffer->endElement();
}
}
示例6: 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);
}
}
示例7: getInfoByCode
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);
}
示例8: 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;
}
示例9: saveToFile
/**
* @param string $fileToSave
* @param number $offsetStart
* @param number $limit
* @param null | string $suffix
*
* @return string
*/
protected function saveToFile($fileToSave, $offsetStart, $limit, $suffix = null)
{
$writer = new \XMLWriter();
$path = pathinfo($fileToSave);
$filePath = $path['dirname'] . '/' . $path['filename'];
if (!is_null($suffix)) {
$filePath .= self::SEPERATOR . $suffix;
}
if (empty($path['extension'])) {
$filePath .= self::XML_EXT;
} else {
$filePath .= '.' . $path['extension'];
}
$writer->openURI($filePath);
$writer->startDocument('1.0', 'UTF-8');
$writer->setIndent(true);
$writer->startElement('sitemapindex');
$writer->writeAttribute('xmlns', self::SCHEMA);
for ($i = $offsetStart; $i < count($this->items) && $i < $limit; $i++) {
$item = $this->items[$i];
$writer->startElement('sitemap');
$writer->writeElement('loc', $item['url']);
$writer->writeElement('lastmod', $item['modified']->format(ModifiableInterface::MODIFIED_DATE_FORMAT));
$writer->endElement();
}
$writer->endElement();
$writer->endDocument();
return $filePath;
}
示例10: 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();
}
示例11: 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();
}
示例12: 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;
}
示例13: 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;
}
示例14: finalize
public function finalize()
{
$this->xml->endElement();
//root element
$this->xml->endDocument();
$this->xml->flush();
return $this->filename;
}
示例15: _addNumber
/**
* add number
*
* @param integer $_number
* @param string $_type
*/
protected function _addNumber($_number, $_type)
{
$this->_writer->startElement("number");
$this->_writer->writeAttribute("type", $_type);
$this->_writer->writeAttribute("quickdial", "");
$this->_writer->writeAttribute("vanity", "");
$this->_writer->writeAttribute("prio", "");
$this->_writer->text($_number);
$this->_writer->endElement();
}