当前位置: 首页>>代码示例>>PHP>>正文


PHP XMLWriter::writeCdata方法代码示例

本文整理汇总了PHP中XMLWriter::writeCdata方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLWriter::writeCdata方法的具体用法?PHP XMLWriter::writeCdata怎么用?PHP XMLWriter::writeCdata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLWriter的用法示例。


在下文中一共展示了XMLWriter::writeCdata方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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();
     }
 }
开发者ID:marcw,项目名称:rss-writer,代码行数:27,代码来源:ItunesWriter.php

示例2: get

 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();
 }
开发者ID:MenZil-Team,项目名称:inews,代码行数:26,代码来源:SiteMap.php

示例3: handleElement

 /**
  * Method for parsing of elements
  *
  * @param string $node - node name
  * @param string $item - node content
  * @param bool $wrap - should be wrapped in array for singularization
  *
  * @return void
  *
  * @since 1.0
  */
 protected function handleElement($node, $item, $wrap = true)
 {
     if ($this->dispatcher->listensTo($node)) {
         $this->dispatcher->trigger($node, array($this->writer, $node, $item));
     } else {
         if ($node === self::COMMENT) {
             if (!is_array($item)) {
                 $item = array($item);
             }
             foreach ($item as $comment) {
                 $this->writer->writeComment($comment);
             }
         } elseif ($node === self::CDATA) {
             $this->writer->writeCdata($item);
         } else {
             if ($wrap === true) {
                 if ($this->assertElementName($node)) {
                     if ($this->config->nil_on_null === true && is_null($item)) {
                         $this->writer->startElement($node);
                         $this->writer->writeAttribute('xsi:nil', 'true');
                         $this->writer->writeRaw($item);
                         $this->writer->endElement();
                     } else {
                         $this->writer->writeElement($node, $item);
                     }
                 }
             } else {
                 $this->writer->writeRaw($item);
             }
         }
     }
 }
开发者ID:realshadow,项目名称:serializers,代码行数:43,代码来源:Xml.php

示例4: dumpElement

 protected function dumpElement($key, $value)
 {
     $this->xml->startElement(strtolower(preg_replace('/[^a-zA-Z0-9]/', '', $key)));
     if (is_array($value)) {
         foreach ($value as $subKey => $subValue) {
             $this->dumpElement($subKey, $subValue);
         }
     } else {
         //need CDATA
         if (preg_match('/[<>&]/', $value)) {
             $this->xml->writeCdata($value);
         } else {
             $this->xml->text($value);
         }
     }
     $this->xml->endElement();
 }
开发者ID:csanquer,项目名称:fakery-generator,代码行数:17,代码来源:XMLDumper.php

示例5: generate

 /**
  * Generates the export
  *
  * @param integer $categoryId Category Id
  * @param boolean $downwards  If true, downwards, otherwise upward ordering
  * @param string  $language   Language
  *
  * @return string
  */
 public function generate($categoryId = 0, $downwards = true, $language = '')
 {
     global $PMF_LANG;
     // Initialize categories
     $this->category->transform($categoryId);
     $faqdata = $this->faq->get(FAQ_QUERY_TYPE_EXPORT_XHTML, $categoryId, $downwards, $language);
     $version = $this->_config->get('main.currentVersion');
     $comment = sprintf('XHTML output by phpMyFAQ %s | Date: %s', $version, PMF_Date::createIsoDate(date("YmdHis")));
     $this->xml->startDocument('1.0', 'utf-8');
     $this->xml->writeDtd('html', '-//W3C//DTD XHTML 1.0 Transitional//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd');
     $this->xml->startElement('html');
     $this->xml->writeAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
     $this->xml->writeAttribute('xml:lang', $language);
     $this->xml->writeComment($comment);
     $this->xml->startElement('head');
     $this->xml->writeElement('title', $this->_config->get('main.titleFAQ'));
     $this->xml->startElement('meta');
     $this->xml->writeAttribute('http-equiv', 'Content-Type');
     $this->xml->writeAttribute('content', 'application/xhtml+xml; charset=utf-8');
     $this->xml->endElement();
     $this->xml->endElement();
     // </head>
     $this->xml->startElement('body');
     $this->xml->writeAttribute('dir', $PMF_LANG['dir']);
     if (count($faqdata)) {
         $lastCategory = 0;
         foreach ($faqdata as $data) {
             if ($data['category_id'] != $lastCategory) {
                 $this->xml->writeElement('h1', $this->category->getPath($data['category_id'], ' >> '));
             }
             $this->xml->writeElement('h2', strip_tags($data['topic']));
             $this->xml->startElement('p');
             $this->xml->writeCdata(html_entity_decode($data['content'], ENT_QUOTES, 'UTF-8'));
             $this->xml->endElement();
             $this->xml->writeElement('p', $PMF_LANG['msgAuthor'] . ': ' . $data['author_email']);
             $this->xml->writeElement('p', $PMF_LANG['msgLastUpdateArticle'] . PMF_Date::createIsoDate($data['lastmodified']));
             $lastCategory = $data['category_id'];
         }
     }
     $this->xml->endElement();
     // </body>
     $this->xml->endElement();
     // </html>
     header('Content-type: text/html');
     return $this->xml->outputMemory();
 }
开发者ID:kapljr,项目名称:Jay-Kaplan-Farmingdale-BCS-Projects,代码行数:55,代码来源:Xhtml.php

示例6: writePoNumber

 /**
  * Write purchase order info to order
  * @param Mage_Sales_Model_Order $order
  * @param XMLWriter $xml
  */
 public function writePoNumber($order, $xml)
 {
     $payment = $order->getPayment();
     $xml->startElement('PO');
     if ($payment) {
         $xml->writeCdata($payment->getPoNumber());
     }
     $xml->endElement();
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:14,代码来源:Data.php

示例7: foreach

$rss->writeElement('title', $faqconfig->get('main.titleFAQ') . ' - ' . $PMF_LANG['msgNews']);
$rss->writeElement('description', html_entity_decode($faqconfig->get('main.metaDescription')));
$rss->writeElement('link', PMF_Link::getSystemUri('/feed/news/rss.php'));
if ($num > 0) {
    foreach ($rssData as $item) {
        // Get the url
        $link = '/index.php?action=news&amp;newsid=' . $item['id'] . '&amp;newslang=' . $item['lang'];
        if (PMF_RSS_USE_SEO) {
            if (isset($item['header'])) {
                $oLink = new PMF_Link($link);
                $oLink->itemTitle = $item['header'];
                $link = $oLink->toString();
            }
        }
        $rss->startElement('item');
        $rss->writeElement('title', html_entity_decode($item['header']));
        $rss->startElement('description');
        $rss->writeCdata($item['content']);
        $rss->endElement();
        $rss->writeElement('link', PMF_Link::getSystemUri('/feed/news/rss.php') . $link);
        $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item['date'], true));
        $rss->endElement();
    }
}
$rss->endElement();
$rss->endElement();
$rssData = $rss->outputMemory();
header('Content-Type: application/rss+xml');
header('Content-Length: ' . strlen($rssData));
print $rssData;
$db->dbclose();
开发者ID:nosch,项目名称:phpMyFAQ,代码行数:31,代码来源:rss.php

示例8: writeDestino

 private function writeDestino(\XMLWriter $writer, Destino $destino)
 {
     if ($destino instanceof DestinoNacional) {
         $writer->startElement('nacional');
         $writer->startElement('bairro_destinatario');
         $writer->writeCdata($this->_($destino->getBairro(), 30));
         $writer->endElement();
         $writer->startElement('cidade_destinatario');
         $writer->writeCdata($this->_($destino->getCidade(), 30));
         $writer->endElement();
         $writer->writeElement('uf_destinatario', $this->_($destino->getUf(), 2, false));
         $writer->startElement('cep_destinatario');
         $writer->writeCdata($this->_(preg_replace('/[^\\d]/', '', $destino->getCep()), 8));
         $writer->endElement();
         $writer->writeElement('codigo_usuario_postal');
         $writer->writeElement('centro_custo_cliente');
         $writer->writeElement('numero_nota_fiscal', $destino->getNumeroNotaFiscal());
         $writer->writeElement('serie_nota_fiscal', $this->_($destino->getSerieNotaFiscal(), 20));
         $writer->writeElement('valor_nota_fiscal', $destino->getValorNotaFiscal());
         $writer->writeElement('natureza_nota_fiscal', $this->_($destino->getNaturezaNotaFiscal(), 20));
         $writer->startElement('descricao_objeto');
         $writer->writeCdata($this->_($destino->getDescricaoObjeto(), 20));
         $writer->endElement();
         $writer->writeElement('valor_a_cobrar', (double) $destino->getValorACobrar());
         $writer->endElement();
     } else {
         if ($destino instanceof DestinoInternacional) {
             $writer->startElement('internacional');
             $writer->endElement();
         }
     }
 }
开发者ID:rorteg,项目名称:php-sigep,代码行数:32,代码来源:FecharPreListaDePostagem.php

示例9: exportTable


//.........这里部分代码省略.........
         $arrData[] = $arrRow;
     }
     // xml-output
     if ($exportType == 'xml') {
         $objXml = new \XMLWriter();
         $objXml->openMemory();
         $objXml->setIndent(true);
         $objXml->setIndentString("\t");
         $objXml->startDocument('1.0', $strDestinationCharset != '' ? $strDestinationCharset : 'UTF-8');
         $objXml->startElement($strTable);
         foreach ($arrData as $row => $arrRow) {
             // Headline
             if ($row == 0) {
                 continue;
             }
             // New row
             $objXml->startElement('datarecord');
             //$objXml->writeAttribute('index', $row);
             foreach ($arrRow as $i => $fieldvalue) {
                 // New field
                 $objXml->startElement($arrHeadline[$i]);
                 // Write Attributes
                 //$objXml->writeAttribute('name', $arrHeadline[$i]);
                 //$objXml->writeAttribute('type', gettype($fieldvalue));
                 //$objXml->writeAttribute('origtype', $arrFieldInfo[$arrHeadline[$i]]['type']);
                 // Convert to charset
                 if ($strDestinationCharset != '') {
                     $fieldvalue = iconv("UTF-8", $strDestinationCharset, $fieldvalue);
                 }
                 if (is_numeric($fieldvalue) || is_null($fieldvalue) || $fieldvalue == '') {
                     $objXml->text($fieldvalue);
                 } else {
                     // Write CDATA
                     $objXml->writeCdata($fieldvalue);
                 }
                 $objXml->endElement();
                 //end field-tag
             }
             $objXml->endElement();
             // End row-tag
         }
         $objXml->endElement();
         // End table-tag
         $objXml->endDocument();
         $xml = $objXml->outputMemory();
         // Write output to file system
         if ($strDestination != '') {
             new \Folder($strDestination);
             $objFolder = \FilesModel::findByPath($strDestination);
             if ($objFolder !== null) {
                 if ($objFolder->type == 'folder' && is_dir(TL_ROOT . '/' . $objFolder->path)) {
                     $objFile = new \File($objFolder->path . '/' . $strTable . '_' . \Date::parse('Y-m-d_H-i-s') . '.csv');
                     $objFile->write($xml);
                     $objFile->close();
                     return;
                 }
             }
         }
         // Send file to browser
         header('Content-type: text/xml');
         header('Content-Disposition: attachment; filename="' . $strTable . '.xml"');
         echo $xml;
         exit;
     }
     // csv-output
     if ($exportType == 'csv') {
开发者ID:markocupic,项目名称:export_table,代码行数:67,代码来源:ExportTable.php

示例10: DublinCoreOutput


//.........这里部分代码省略.........
         .'LEFT JOIN mst_location AS loc ON i.location_id=loc.location_id '
         .'WHERE i.biblio_id='.$this->detail_id);
     if ($_copy_q->num_rows > 0) {
         while ($_copy_d = $_copy_q->fetch_assoc()) {
             $_xml_output .= '<dc:hasPart><![CDATA['.utf8_encode($_copy_d['item_code']).']]></dc:hasPart>'."\n";
         }
     }
     
     // digital files
     $attachment_q = $this->obj_db->query('SELECT att.*, f.* FROM biblio_attachment AS att
         LEFT JOIN files AS f ON att.file_id=f.file_id WHERE att.biblio_id='.$this->detail_id.' AND att.access_type=\'public\' LIMIT 20');
     if ($attachment_q->num_rows > 0) {
       while ($attachment_d = $attachment_q->fetch_assoc()) {
           $dir = '';
           if ($attachment_d['file_dir']) {
             $dir = $attachment_d['file_dir'].'/';
           }
           $_xml_output .= '<dc:relation><![CDATA[';
           // check member type privileges
           if ($attachment_d['access_limit']) { continue; }
           $_xml_output .= $protocol.'://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].REPO_WBS.$dir.trim(urlencode($attachment_d['file_name']));
           $_xml_output .= ']]></dc:relation>'."\n";
       }
     }
     
     // image
     if (!empty($this->record_detail['image'])) {
       $_image = urlencode($this->record_detail['image']);
     	  $_xml_output .= '<dc:relation><![CDATA['.$protocol.'://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].SWB.'images/docs/'.urlencode($_image).']]></dc:relation>'."\n";
     }
     */
     // title
     $xml->startElementNS('dc', 'title', null);
     $xml->writeCdata($_title_main);
     $xml->endElement();
     // get the authors data
     $_biblio_authors_q = $this->obj_db->query('SELECT a.*,ba.level FROM mst_author AS a' . ' LEFT JOIN biblio_author AS ba ON a.author_id=ba.author_id WHERE ba.biblio_id=' . $this->detail_id);
     while ($_auth_d = $_biblio_authors_q->fetch_assoc()) {
         $xml->startElementNS('dc', 'creator', null);
         $xml->writeCdata($_auth_d['author_name']);
         $xml->endElement();
     }
     $_biblio_authors_q->free_result();
     // imprint/publication data
     $xml->startElementNS('dc', 'publisher', null);
     $xml->writeCdata($this->record_detail['publisher_name']);
     $xml->endElement();
     if ($this->record_detail['publish_year']) {
         $xml->startElementNS('dc', 'date', null);
         $xml->writeCdata($this->record_detail['publish_year']);
         $xml->endElement();
     } else {
         $xml->startElementNS('dc', 'date', null);
         $xml->fullEndElement();
     }
     // edition
     $xml->startElementNS('dc', 'hasVersion', null);
     $xml->writeCdata($this->record_detail['edition']);
     $xml->endElement();
     // language
     $xml->startElementNS('dc', 'language', null);
     $xml->writeCdata($this->record_detail['language_name']);
     $xml->endElement();
     // Physical Description/Collation
     $xml->startElementNS('dc', 'medium', null);
     $xml->writeCdata($this->record_detail['gmd_name']);
开发者ID:banumelody,项目名称:slims7_cendana,代码行数:67,代码来源:detail.inc.php

示例11: die

$writer->startElement('resultset');
$scormcontent = simplexml_load_file('scorm_content.xml') or die('wtf');
foreach ($scormcontent->children() as $scormdetails) {
    $courseid = (int) $scormdetails->field['0'];
    $cmid = (int) $scormdetails->field['1'];
    $scormid = (int) $scormdetails->field['2'];
    $coursename = (string) $scormdetails->field['3'];
    $scormname = (string) $scormdetails->field['4'];
    $filename = (string) $scormdetails->field['5'];
    if (!file_exists($scormfolder . $filename)) {
        $notfound[] = $filename;
        $writer->startElement('row');
        // course_id
        $writer->startElement('field');
        $writer->writeAttribute('name', 'course_id');
        $writer->writeCdata($courseid);
        $writer->endElement();
        // course_module_id
        $writer->startElement('field');
        $writer->writeAttribute('name', 'course_module_id');
        $writer->writeCdata($cmid);
        $writer->endElement();
        // scorm_id
        $writer->startElement('field');
        $writer->writeAttribute('name', 'scorm_id');
        $writer->writeCdata($scormid);
        $writer->endElement();
        // course_name
        $writer->startElement('field');
        $writer->writeAttribute('name', 'course_name');
        $writer->writeCdata($coursename);
开发者ID:edwinp-catalyst-eu,项目名称:generate-missing-scorm-xml,代码行数:31,代码来源:generate-missing-scorm-details-cli.php

示例12: XMLWriter

$category = new PMF_Category();
$faq = new PMF_Faq();
$records = $faq->getAllRecordPerCategory($category_id, $faqconfig->get('records.orderby'), $faqconfig->get('records.sortby'));
$rss = new XMLWriter();
$rss->openMemory();
$rss->startDocument('1.0', $PMF_LANG['metaCharset']);
$rss->startElement('rss');
$rss->writeAttribute('version', '2.0');
$rss->startElement('channel');
$rss->writeElement('title', utf8_encode($PMF_CONF['main.titleFAQ']) . ' - ');
$rss->writeElement('description', utf8_encode($PMF_CONF['main.metaDescription']));
$rss->writeElement('link', PMF_Link::getSystemUri('/feed/category/rss.php'));
if (is_array($records)) {
    foreach ($records as $item) {
        $rss->startElement('item');
        $rss->writeElement('title', utf8_encode($item['record_title'] . ' (' . $item['visits'] . ' ' . $PMF_LANG['msgViews'] . ')'));
        $rss->startElement('description');
        $rss->writeCdata(utf8_encode($item['record_preview']));
        $rss->endElement();
        $rss->writeElement('link', utf8_encode($item['record_link']));
        $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item['record_date'], true));
        $rss->endElement();
    }
}
$rss->endElement();
$rss->endElement();
$rssData = $rss->outputMemory();
header('Content-Type: application/rss+xml');
header('Content-Length: ' . strlen($rssData));
print $rssData;
$db->dbclose();
开发者ID:noon,项目名称:phpMyFAQ,代码行数:31,代码来源:rss.php

示例13: objectToXml

 /**
  * Handles conversion of objects into a string format that can be exported in our
  * XML format.
  *
  * Note: currently only ImageVariant instances are supported.
  *
  * @param $object
  * @param \XMLWriter $xmlWriter
  * @return void
  */
 protected function objectToXml($object, \XMLWriter $xmlWriter)
 {
     $className = get_class($object);
     switch ($className) {
         case 'TYPO3\\Media\\Domain\\Model\\ImageVariant':
             $xmlWriter->startElement('processingInstructions');
             $xmlWriter->writeCdata(serialize($object->getProcessingInstructions()));
             $xmlWriter->endElement();
             $xmlWriter->startElement('originalImage');
             $xmlWriter->writeAttribute('__type', 'object');
             $xmlWriter->writeAttribute('__classname', '\\TYPO3\\Media\\Domain\\Model\\Image');
             $xmlWriter->startElement('resource');
             $xmlWriter->writeAttribute('__type', 'object');
             $xmlWriter->writeAttribute('__classname', '\\TYPO3\\FLOW3\\Resource\\Resource');
             $resource = $object->getOriginalImage()->getResource();
             $xmlWriter->writeElement('filename', $resource->getFilename());
             $xmlWriter->writeElement('content', base64_encode(file_get_contents($resource->getUri())));
             $xmlWriter->endElement();
             $xmlWriter->endElement();
             break;
         default:
             throw new \TYPO3\TYPO3\Domain\Exception('Unsupported object of type "' . get_class($className) . '" hit during XML export.', 1347144928);
     }
 }
开发者ID:radmiraal,项目名称:TYPO3.TYPO3,代码行数:34,代码来源:SiteExportService.php

示例14: foreach

    foreach ($rssData as $item) {
        // Get the url
        $link = str_replace($_SERVER['SCRIPT_NAME'], '/index.php', $item['url']);
        if (PMF_RSS_USE_SEO) {
            if (isset($item['thema'])) {
                $oLink = new PMF_Link($link);
                $oLink->itemTitle = html_entity_decode($item['thema'], ENT_COMPAT, 'UTF-8');
                $link = html_entity_decode($oLink->toString(), ENT_COMPAT, 'UTF-8');
            }
        }
        // Get the content
        $content = $item['content'];
        // Fix the content internal image references
        $content = str_replace("<img src=\"/", "<img src=\"" . PMF_Link::getSystemUri('/feed/latest/rss.php') . "/", $content);
        $rss->startElement('item');
        $rss->writeElement('title', html_entity_decode($item['thema'], ENT_COMPAT, 'UTF-8'));
        $rss->startElement('description');
        $rss->writeCdata($content);
        $rss->endElement();
        $rss->writeElement('link', PMF_Link::getSystemUri('/feed/latest/rss.php') . $link);
        $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item['datum'], true));
        $rss->endElement();
    }
}
$rss->endElement();
$rss->endElement();
$rssData = $rss->outputMemory();
header('Content-Type: application/rss+xml');
header('Content-Length: ' . strlen($rssData));
print $rssData;
$db->dbclose();
开发者ID:rybal06,项目名称:phpMyFAQ,代码行数:31,代码来源:rss.php

示例15: createXmlDocument

 /**
  * Create a new XML document based on the $content variable.
  *
  * @param   string  $content
  * @throws  \ErrorException
  * @return  Boolean|string
  */
 private function createXmlDocument(&$content)
 {
     libxml_use_internal_errors(true);
     $xmlContent = simplexml_load_string($content);
     $document = new \XMLWriter();
     if (!$xmlContent) {
         throw new \ErrorException('The supplied content is not an XML document');
     }
     if (!isset($xmlContent->children()->name)) {
         return false;
     }
     $document->openMemory();
     $document->startDocument('1.0', 'UTF-8');
     $document->setIndent(true);
     $document->setIndentString('    ');
     $document->writeDtd(sprintf('extension PUBLIC "-//Joomla! %s//DTD template 1.0//EN" "https://intowebdevelopment.nl/dtd/joomla/%s/template-install.dtd"', DTD_JOOMLA_VERSION, DTD_JOOMLA_VERSION));
     $document->startElement('extension');
     $document->writeAttribute('version', TARGET_JOOMLA_VERSION);
     $document->writeAttribute('type', 'template');
     $document->writeAttribute('client', TARGET_JOOMLA_TEMPLATE);
     $document->writeAttribute('method', 'upgrade');
     $document->writeElement('name', (string) $xmlContent->children()->name);
     $document->writeElement('creationDate', (string) $xmlContent->children()->creationDate ?: date('Y-m-d'));
     $document->writeElement('author', (string) $xmlContent->children()->author);
     $document->writeElement('authorEmail', (string) $xmlContent->children()->authorEmail);
     $document->writeElement('authorUrl', (string) $xmlContent->children()->authorUrl);
     $document->writeElement('version', (string) $xmlContent->children()->version);
     $document->writeElement('license', (string) $xmlContent->children()->license);
     $document->startElement('description');
     $document->writeCdata((string) $xmlContent->children()->description);
     $document->endElement();
     $document->startElement('files');
     $contains_templateDetails = false;
     foreach ($xmlContent->children()->files->children() as $file) {
         if (!is_file($this->directory . DIRECTORY_SEPARATOR . (string) $file)) {
             throw new FileNotFoundException((string) $file);
         }
         $contains_templateDetails = false !== strpos((string) $file, 'templateDetails.xml');
         $document->writeElement($file->getName(), (string) $file);
     }
     if (!$contains_templateDetails) {
         $document->writeElement('filename', 'templateDetails.xml');
     }
     $document->endElement();
     $document->startElement('positions');
     foreach ($xmlContent->children()->positions->children() as $position) {
         $document->writeElement('position', (string) $position);
     }
     $document->endElement();
     if (isset($xmlContent->children()->languages)) {
         $document->startElement('languages');
         foreach ($xmlContent->children()->languages->children() as $language) {
             $document->startElement('language');
             $document->writeAttribute('tag', (string) $language->attributes()->tag);
             $document->text((string) $language);
             $document->endElement();
         }
         $document->endElement();
     }
     if (isset($xmlContent->children()->params)) {
         $document->startElement('config');
         $document->startElement('fields');
         $document->writeAttribute('name', 'params');
         if (($addPath = $xmlContent->children()->params->attributes()->addpath) && isset($addPath)) {
             $document->writeAttribute('addfieldpath', (string) $addPath);
         }
         $document->startElement('fieldset');
         $document->writeAttribute('name', 'advanced');
         foreach ($xmlContent->children()->params->children() as $param) {
             $document->startElement('field');
             $document->writeAttribute('name', (string) $param->attributes()->name);
             $document->writeAttribute('type', (string) $param->attributes()->type);
             $document->writeAttribute('default', (string) $param->attributes()->default);
             $document->writeAttribute('label', (string) $param->attributes()->label);
             $document->writeAttribute('description', (string) $param->attributes()->description);
             if (0 < $param->count()) {
                 foreach ($param->children() as $option) {
                     $document->startElement('option');
                     $document->writeAttribute('value', (string) $option->attributes()->value);
                     $document->text((string) $option);
                     $document->endElement();
                 }
             }
             $document->endElement();
         }
         $document->endElement();
         $document->endElement();
         $document->endElement();
     }
     $document->endElement();
     return $content = $document->outputMemory(true);
 }
开发者ID:intowebdevelopment,项目名称:joomlatemplateconverter,代码行数:99,代码来源:Parser.php


注:本文中的XMLWriter::writeCdata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。