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


PHP XMLWriter::writePI方法代码示例

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


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

示例1: toXmlStr

 public function toXmlStr($xmlns = null, $xmlname = null)
 {
     if ($xmlns === null) {
         $xmlns = static::NS;
     }
     if ($xmlname === null) {
         $xmlname = static::ROOT;
     }
     $xw = new \XMLWriter();
     $xw->openMemory();
     $xw->setIndent(TRUE);
     $xw->startDocument("1.0", "UTF-8");
     if ($this->PI) {
         $xw->writePI("xml-stylesheet", "type=\"text/xsl\" href=\"" . $this->PI . "\"");
     }
     $this->toXmlWriter($xw, $xmlname, $xmlns);
     $xw->endDocument();
     return $xw->flush();
 }
开发者ID:servandserv,项目名称:happymeal,代码行数:19,代码来源:AnyType.php

示例2: getXML

 function getXML($feed_format = RSS_2_0, $category_filter = null)
 {
     $elementNestLevel = 0;
     //Set the default timezone
     @date_default_timezone_set("GMT");
     //Create the xml write object
     $writer = new XMLWriter();
     //XMLWriter Output method:
     //------------------------------------------------------------------------------------------
     $writer->openMemory();
     //	Xml stored in memory (allows set as variable, output
     //  to file, print/echo	to user, etc.
     //$this->$writer->openURI('php://output');  	//	Send xml to directly to browser/user (not implemented in this version)
     //-----------------------------------------------------------------------------------------
     //XML Version.  Include Charachter Encoding if supplied
     if ($this->feedSpecs['xmlEncodeAs'] != null) {
         $writer->startDocument('1.0', $this->feedSpecs['xmlEncodeAs']);
     } else {
         $writer->startDocument('1.0');
     }
     //Add stylesheet details if provided
     foreach ($this->feedSpecs['feedStylesheet'] as $curStylesheet) {
         $writer->writePI("xml-stylesheet", 'type="' . $curStylesheet['type'] . '" href="' . $curStylesheet['address'] . '"');
     }
     //------------------------------------------
     //Indent level
     $writer->setIndent($this->indent);
     //Validate and display notice if not valid
     if ($this->feedSpecs['enableValidation'] && !$this->validate($feed_format)) {
         //Validation Enabled.  Feed is not valid for the specified output format.
         //echo $err_message;
         //exit;
         $writer->flush();
         $this->invalidFeed($feed_format);
     }
     //Instantiate the FeedConstruct class
     $this->set_feedConstruct($feed_format);
     $this->set_docs($this->feed_construct->docsUrl);
     //Set content type for specified output format
     $this->feed_construct->setHeaderContentType($this->feed_construct->format);
     //Get root, set current as root construct
     $current = $this->feed_construct->getConstruct(ROOT_CONSTRUCT);
     //Start the root element
     $writer->startElement($current['elementName']);
     $elementNestLevel++;
     //add attributes if available
     foreach ($current['attributes'] as $curAttribute) {
         $writer->writeAttribute($curAttribute[1], $curAttribute[3]);
     }
     //add custom namespaces if available
     foreach ($this->feedSpecs['feedXMLNameSpace'] as $curNS) {
         $writer->writeAttribute('xmlns:' . $curNS['prefix'], $curNS['url']);
     }
     //Get root construct children
     $children = $this->feed_construct->getChildren($current['commonName']);
     //Check if has feed channel (sub) element (Channel)
     if (count($children) > 0 && $children[0]['commonName'] == CHANNEL_DATA_CONSTRUCT) {
         //Move to CHANNEL_DATA_CONSTRUCT
         $current = $children[0];
         //Start the element
         $writer->startElement($current['elementName']);
         $elementNestLevel++;
         //add attributes if available
         if ($current['attributes'] !== null) {
             foreach ($current['attributes'] as $curAttribute) {
                 if ($curAttribute[0] != 'default' && isset($this->feedData[$curAttribute[0]])) {
                     //populated with feed data
                     $writer->writeAttribute($curAttribute[1], $this->feedData[$curAttribute[0]]);
                 } elseif ($curAttribute[0] == 'default') {
                     //Populated with constant value
                     $writer->writeAttribute($curAttribute[1], $curAttribute[3]);
                 }
             }
         }
         //Get get feed channel data constructs
         $children = $this->feed_construct->getChildren($current['commonName']);
     }
     $atItemConstruct = false;
     //Loop through Feed Data Elements (stop if reached item construct)
     foreach ($children as $curConstruct) {
         if ($curConstruct['commonName'] == ITEM_CONSTRUCT) {
             $atItemConstruct = true;
             break;
         } else {
             //Test if feed has data for the current construct.  Skip if not.
             if (isset($this->feedData[$curConstruct['commonName']]) && $this->feedData[$curConstruct['commonName']] != null) {
                 $iterator = 0;
                 $mult = true;
                 //Proceed single node in feedData array, or loop through set if multiple.
                 do {
                     if ($curConstruct['max'] > 1 && $iterator >= $curConstruct['max']) {
                         //Allws multiple, but has reached limit
                         $mult = false;
                     } elseif ($curConstruct['max'] != 1) {
                         if (isset($this->feedData[$curConstruct['commonName']][$iterator])) {
                             $this->writeConstruct($writer, $this->feedData[$curConstruct['commonName']][$iterator], $curConstruct, $curConstruct['commonName']);
                             $iterator++;
                         } else {
                             //Reached end of feed data array.
                             $mult = false;
//.........这里部分代码省略.........
开发者ID:nguyendev,项目名称:LoveSharing,代码行数:101,代码来源:FeedWriter.php


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