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


PHP XmlWriter::writeRaw方法代码示例

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


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

示例1: html

 public function html($mysqli_stmt)
 {
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString("\t");
     $xml->startElement('table');
     $xml->writeAttribute('class', $this->tbl_class);
     $xml->startElement('thead');
     $xml->startElement('tr');
     //////////////////////////////////
     // Column Headers
     /////////////////////////////////
     $cntcol = count($this->col_classes);
     $altcol = 0;
     foreach (array_keys($this->cols) as $th) {
         $xml->startElement('th');
         $xml->writeAttribute('scope', 'col');
         if ($this->col_classes[$altcol] != "") {
             $xml->writeAttribute('class', $this->col_classes[$altcol]);
         }
         $altcol = ++$altcol % $cntcol;
         if (substr($th, 0, 2) == "__") {
             $xml->text('');
         } else {
             //Sorting
             $dir = "A";
             if (isset($_GET["sn"]) && $_GET["sn"] == $th && $_GET["sd"] == "A") {
                 $dir = "D";
             }
             $xml->startElement('a');
             $xml->startAttribute('href');
             $xml->writeRaw(quickgrid::get_href(["sn" => $th, "sd" => $dir, "p" => 1]));
             $xml->endAttribute();
             $xml->text($th);
             $xml->endElement();
             //a
         }
         $xml->endElement();
         //th
     }
     $xml->endElement();
     //tr
     $xml->endElement();
     //thead
     $xml->startElement('tfoot');
     $xml->startElement('tr');
     $xml->startElement('td');
     $xml->writeAttribute('colspan', count($this->cols));
     //////////////////////////////////
     // Pager
     /////////////////////////////////
     $last = ceil($this->row_count / $this->per_page);
     $length = 8;
     $lbound = $this->cur_page - $length / 2;
     $ubound = $this->cur_page + $length / 2;
     if ($lbound < 1) {
         $lbound = 1;
     }
     if ($ubound > $last) {
         $ubound = $last;
     }
     if ($this->cur_page != 1) {
         $xml->startElement('a');
         $xml->startAttribute('href');
         $xml->writeRaw(quickgrid::get_href(["p" => $this->cur_page - 1]));
         $xml->endAttribute();
         $xml->text("<");
         $xml->endElement();
         //a
     }
     for ($i = $lbound; $i <= $ubound; $i++) {
         if ($i != $this->cur_page) {
             $xml->startElement('a');
             $xml->startAttribute('href');
             $xml->writeRaw(quickgrid::get_href(["p" => $i]));
             $xml->endAttribute();
             $xml->text("{$i}");
             $xml->endElement();
             //a
         } else {
             $xml->startElement('span');
             $xml->text("{$i}");
             $xml->endElement();
             //span
         }
     }
     if ($this->cur_page != $last) {
         $xml->startElement('a');
         $xml->startAttribute('href');
         $xml->writeRaw(quickgrid::get_href(["p" => $this->cur_page + 1]));
         $xml->endAttribute();
         $xml->text(">");
         $xml->endElement();
         //a
     }
     $xml->endElement();
     //td
     $xml->endElement();
     //tr
//.........这里部分代码省略.........
开发者ID:jclifford0251,项目名称:quickphp,代码行数:101,代码来源:quickgrid.php

示例2: objectSerialize

 /** 
  * Serialize an object with specified root element name. 
  * 
  * @param object $targetObject The target object. 
  * @param string $rootName     The name of the root element. 
  * 
  * @return string
  */
 public static function objectSerialize($targetObject, $rootName)
 {
     Validate::notNull($targetObject, 'targetObject');
     Validate::isString($rootName, 'rootName');
     $xmlWriter = new \XmlWriter();
     $xmlWriter->openMemory();
     $xmlWriter->setIndent(true);
     $reflectionClass = new \ReflectionClass($targetObject);
     $methodArray = $reflectionClass->getMethods();
     $attributes = self::_getInstanceAttributes($targetObject, $methodArray);
     $xmlWriter->startElement($rootName);
     if (!is_null($attributes)) {
         foreach (array_keys($attributes) as $attributeKey) {
             $xmlWriter->writeAttribute($attributeKey, $attributes[$attributeKey]);
         }
     }
     foreach ($methodArray as $method) {
         if (strpos($method->name, 'get') === 0 && $method->isPublic() && $method->name != 'getAttributes') {
             $variableName = substr($method->name, 3);
             $variableValue = $method->invoke($targetObject);
             if (!empty($variableValue)) {
                 if (gettype($variableValue) === 'object') {
                     $xmlWriter->writeRaw(XmlSerializer::objectSerialize($variableValue, $variableName));
                 } else {
                     $xmlWriter->writeElement($variableName, $variableValue);
                 }
             }
         }
     }
     $xmlWriter->endElement();
     return $xmlWriter->outputMemory(true);
 }
开发者ID:bitmovin,项目名称:azure-sdk-for-php,代码行数:40,代码来源:XmlSerializer.php


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