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


PHP XmlWriter::setIndentString方法代码示例

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


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

示例1: begin

 public function begin()
 {
     $this->writer->openMemory();
     $this->writer->setIndent(true);
     $this->writer->setIndentString(str_repeat(' ', 4));
     $this->writer->startDocument('1.0', 'UTF-8');
 }
开发者ID:JoshBour,项目名称:karolina,代码行数:7,代码来源:SitemapXmlParser.php

示例2: __construct

 public function __construct()
 {
     parent::openMemory();
     //parent::startDocument(); // this hack avoids the output of the <?xml version="1.0" element
     parent::setIndent(true);
     parent::setIndentString('  ');
 }
开发者ID:rasismeiro,项目名称:cintient,代码行数:7,代码来源:XmlDoc.php

示例3: unset

 function fill_muc_config_form(array $packet, array $fill_info)
 {
     $ret_val_xml = "";
     $header = $packet["iq"]["@"];
     $nested_conf = $packet["iq"]["#"];
     $fields = $nested_conf["query"]["0"]["#"]["x"]["0"]["#"];
     unset($fields["title"]);
     unset($fields["instructions"]);
     unset($nested_conf["query"]["0"]["#"]["x"]["0"]["#"]);
     $header["type"] = "set";
     $to = $header["from"];
     $header["from"] = $header["to"];
     $header["to"] = $to;
     $nested_conf["query"]["0"]["#"]["x"]["0"]["@"]["type"] = "submit";
     foreach ($fill_info as $var => $value) {
         if (!$this->set_field_value($fields["field"], $var, $value)) {
             return false;
         }
     }
     //		var_dump($packet);
     // Building response array
     $response = array("iq" => array("@" => $header, "#" => $nested_conf));
     $response["iq"]["#"]["query"]["0"]["#"]["x"]["0"]["#"] = $fields;
     //		var_dump($response);
     //		var_dump($header);
     //		var_dump($nested_conf);
     //		var_dump($fields);
     /***********************************
      ******** Generate the XML
      ***********************************/
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString(' ');
     // Starting roots (usualy we've got only 1 root for a pck).
     foreach ($response as $key => $value) {
         $xml->startElement($key);
         if (is_array($value)) {
             // Attributes
             if (is_array($value["@"])) {
                 foreach ($value["@"] as $attr => $attr_value) {
                     $xml->writeAttribute($attr, $attr_value);
                 }
             }
             // Nested elements
             if (is_array($value["#"])) {
                 $this->write($xml, $value["#"]);
             }
         }
         $xml->endElement();
         $ret_val_xml = $xml->outputMemory(true);
     }
     return $ret_val_xml;
     //		var_dump($packet);
     //		var_dump($fill_info);
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:56,代码来源:PacketMng.php

示例4: initialise

 private function initialise()
 {
     /* Setting XML header */
     @header("content-type: application/vnd.google-earth.kml+xml; charset=UTF-8");
     /* Initializing the XML Object */
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString('    ');
     $xml->startDocument('1.0', 'UTF-8');
     return $xml;
 }
开发者ID:Abbe98,项目名称:ODOK,代码行数:12,代码来源:FormatKml.php

示例5: getXml

function getXml($results)
{
    $xml = new XmlWriter();
    $xml->openMemory();
    $xml->setIndent(true);
    // new
    $xml->setIndentString("    ");
    // new
    $xml->startDocument('1.0', 'UTF-8');
    $xml->startElement('root');
    write($xml, $results);
    $xml->endElement();
    $xml->endDocument();
    // new
    $data = $xml->outputMemory(true);
    //$file = file_put_contents(APPPATH . '../uploads/data.xml', $data);
    return $data;
}
开发者ID:heptanol,项目名称:Test-git,代码行数:18,代码来源:test.php

示例6: outputXml

 function outputXml($results, $xsltPath)
 {
     /* Setting XML header */
     @header("content-type: text/xml; charset=UTF-8");
     /* Initializing the XML Object */
     $xml = new XmlWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString('    ');
     $xml->startDocument('1.0', 'UTF-8');
     if (isset($xsltPath)) {
         $xml->WritePi('xml-stylesheet', 'type="text/xsl" href="' . $xsltPath . '"');
     }
     $xml->startElement('callback');
     $xml->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $xml->writeAttribute('xsi:noNamespaceSchemaLocation', 'schema.xsd');
     /* Function that converts each array element to an XML node */
     function write(XMLWriter $xml, $data)
     {
         foreach ($data as $key => $value) {
             if (is_array($value)) {
                 if (is_numeric($key)) {
                     #The only time a numeric key would be used is if it labels an array with non-uniqe keys
                     write($xml, $value);
                     continue;
                 } else {
                     $xml->startElement($key);
                     write($xml, $value);
                     $xml->endElement();
                     continue;
                 }
             }
             $xml->writeElement($key, $value);
         }
     }
     /* Calls previously declared function, passing our results array as parameter */
     write($xml, $results);
     /* Closing last XML node */
     $xml->endElement();
     /* Printing the XML */
     echo $xml->outputMemory(true);
 }
开发者ID:Abbe98,项目名称:ODOK,代码行数:42,代码来源:Format.php

示例7: buildXML

 /**
  * Build an XML Data Set
  *
  * @param array $data
  *        	Associative Array containing values to be parsed into an XML Data Set(s)
  * @param string $startElement
  *        	Root Opening Tag, default data
  * @return string XML String containig values
  * @return mixed Boolean false on failure, string XML result on success
  */
 public function buildXML($data, $startElement = 'data')
 {
     if (!is_array($data)) {
         $err = 'Invalid variable type supplied, expected array not found on line ' . __LINE__ . " in Class: " . __CLASS__ . " Method: " . __METHOD__;
         trigger_error($err);
         // if($this->_debug) echo $err;
         return false;
         // return false error occurred
     }
     $xml = new \XmlWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString('    ');
     if ($this->version || $this->encoding) {
         $xml->startDocument($this->version, $this->encoding);
     }
     $xml->startElement($startElement);
     $this->writeEl($xml, $data);
     $xml->endElement();
     // write end element
     // returns the XML results
     return $xml->outputMemory(true);
 }
开发者ID:micoli,项目名称:qd_utils,代码行数:33,代码来源:Array2XML.php

示例8: 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

示例9: outputXml

/**
 * Construct the whole DCAT-AP document given an array of dump info
 *
 * @param array $data data-blob of i18n and config variables
 * @return string: xmldata
 */
function outputXml(array $data)
{
    // Initializing the XML Object
    $xml = new XmlWriter();
    $xml->openMemory();
    $xml->setIndent(true);
    $xml->setIndentString('    ');
    // set namespaces
    $xml->startDocument('1.0', 'UTF-8');
    $xml->startElementNS('rdf', 'RDF', null);
    $xml->writeAttributeNS('xmlns', 'rdf', null, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
    $xml->writeAttributeNS('xmlns', 'dcterms', null, 'http://purl.org/dc/terms/');
    $xml->writeAttributeNS('xmlns', 'dcat', null, 'http://www.w3.org/ns/dcat#');
    $xml->writeAttributeNS('xmlns', 'foaf', null, 'http://xmlns.com/foaf/0.1/');
    $xml->writeAttributeNS('xmlns', 'adms', null, 'http://www.w3.org/ns/adms#');
    $xml->writeAttributeNS('xmlns', 'vcard', null, 'http://www.w3.org/2006/vcard/ns#');
    // Calls previously declared functions to construct xml
    writePublisher($xml, $data);
    writeContactPoint($xml, $data);
    $dataset = array();
    // Live dataset and distributions
    $liveDistribs = writeDistribution($xml, $data, 'ld', null);
    if ($data['config']['api-enabled']) {
        $liveDistribs = array_merge($liveDistribs, writeDistribution($xml, $data, 'api', null));
    }
    array_push($dataset, writeDataset($xml, $data, null, $liveDistribs));
    // Dump dataset and distributions
    if ($data['config']['dumps-enabled']) {
        foreach ($data['dumps'] as $key => $value) {
            $distIds = writeDistribution($xml, $data, 'dump', $key);
            array_push($dataset, writeDataset($xml, $data, $key, $distIds));
        }
    }
    writeCatalog($xml, $data, $dataset);
    // Closing last XML node
    $xml->endElement();
    // Printing the XML
    return $xml->outputMemory(true);
}
开发者ID:wikimedia,项目名称:operations-dumps-dcat,代码行数:45,代码来源:DCAT.php

示例10: generate

 /**
  * Generates the XML output and saves it to a file or returns it as a string
  *
  * @return null|int Returns the number of bytes written to a local file or false on failure
  */
 protected function generate()
 {
     $w = new \XmlWriter();
     $w->openMemory();
     $w->setIndent(true);
     $w->setIndentString("    ");
     $w->startDocument('1.0', 'utf-8');
     $w->startElement($this->rootname);
     $row = $this->getRow();
     $keys = array_keys($row);
     foreach ($keys as $key) {
         $this->isValidName($key);
     }
     do {
         $w->startElement($this->rowname);
         foreach ($row as $key => $value) {
             if ($this->suppress && in_array($key, $this->suppress)) {
                 continue;
             }
             if ($this->hasChildren && in_array($key, $this->hasChildren)) {
                 $stripped = $this->stripHtml($value);
                 $w->startElement($key);
                 foreach ($stripped as $para) {
                     $w->writeElement('p', $para);
                 }
                 $w->endElement();
             } else {
                 $w->writeElement($key, $value);
             }
         }
         $w->endElement();
     } while ($row = $this->getRow());
     $w->endElement();
     $w->endDocument();
     $this->xml = $w->outputMemory();
     // write to file
     if (isset($this->filename) && $this->local) {
         $success = file_put_contents($this->filename, $this->xml);
         return $success;
     } elseif (isset($this->filename) && $this->download) {
         $this->outputHeaders();
         file_put_contents('php://output', $this->xml);
         exit;
     }
 }
开发者ID:sbogdanov108,项目名称:db_to_text,代码行数:50,代码来源:Xml.php

示例11: generate

 /**
  * Generates the XML output and saves it to a file or returns it as a string
  *
  * @return null|int Returns the number of bytes written to a local file or false on failure
  */
 protected function generate()
 {
     $w = new \XmlWriter();
     $w->openMemory();
     $w->setIndent(true);
     $w->setIndentString("    ");
     $w->startDocument('1.0', 'utf-8');
     $w->startElement($this->rootname);
     while ($object = $this->getRow()) {
         // Start a new row for each object
         $w->startElement($this->rowname);
         foreach ($object as $key => $value) {
             if ($this->suppress && in_array($key, $this->suppress)) {
                 continue;
             }
             $this->isValidName($key);
             // Check if the key contains another object
             if (is_object($value)) {
                 // Start parent element containing rows of each object
                 $w->startElement($key . "s");
                 // $value is an array of objects
                 foreach ($value as $obj) {
                     $w->startElement($key);
                     foreach ($obj as $field => $val) {
                         $this->isValidName($key);
                         $w->writeElement($field, $val);
                     }
                     $w->endElement();
                 }
                 $w->endElement();
             } else {
                 // Write each object's property->value as <key>value</key>
                 if ($this->hasChildren && in_array($key, $this->hasChildren)) {
                     $stripped = $this->stripHtml($value);
                     $w->startElement($key);
                     foreach ($stripped as $para) {
                         $w->writeElement('p', $para);
                     }
                     $w->endElement();
                 } else {
                     $w->writeElement($key, $value);
                 }
             }
         }
         $w->endElement();
     }
     $w->endElement();
     $w->endDocument();
     $this->xml = $w->outputMemory();
     // write to file
     if (isset($this->filename) && $this->local) {
         $success = file_put_contents($this->filename, $this->xml);
         return $success;
     } elseif (isset($this->filename) && $this->download) {
         $this->outputHeaders();
         file_put_contents('php://output', $this->xml);
         exit;
     }
 }
开发者ID:Hemant-Mann,项目名称:PHPExport,代码行数:64,代码来源:Xml.php


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