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


PHP XMLWriter::startAttribute方法代码示例

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


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

示例1: showResponse

 /**
  * @param array $params
  * @param string $message
  * @param int $code
  */
 private function showResponse(array $params, $message = '', $code = 0)
 {
     header("Content-type: text/xml; charset=utf-8");
     $writer = new XMLWriter();
     $writer->openURI('php://output');
     $writer->startDocument('1.0', 'UTF-8');
     $writer->startElement($params['action'] . 'Response');
     $writer->startAttribute('performedDatetime');
     $writer->text(date('c'));
     $writer->endAttribute();
     $writer->startAttribute('code');
     $writer->text($code);
     $writer->endAttribute();
     $writer->startAttribute('invoiceId');
     $writer->text($params['invoiceId']);
     $writer->endAttribute();
     $writer->startAttribute('message');
     $writer->text($message);
     $writer->endAttribute();
     $writer->startAttribute('shopId');
     $writer->text($params['shopId']);
     $writer->endAttribute();
     $writer->endElement();
     $writer->endDocument();
     Yii::app()->end();
 }
开发者ID:yupe,项目名称:yupe,代码行数:31,代码来源:YandexMoneyPaymentSystem.php

示例2: beginWriteProperty

 /**
  * Write a property
  *
  * @param ODataProperty &$odataProperty Property to be written
  * @param boolean       $isTopLevel     is link top level or not.
  * 
  * @return nothing
  */
 protected function beginWriteProperty(ODataProperty &$odataProperty, $isTopLevel)
 {
     $this->xmlWriter->startElementNS(ODataConstants::ODATA_NAMESPACE_PREFIX, $odataProperty->name, null);
     if ($odataProperty->typeName != null) {
         $this->xmlWriter->startAttributeNs(ODataConstants::ODATA_METADATA_NAMESPACE_PREFIX, ODataConstants::ATOM_TYPE_ATTRIBUTE_NAME, null);
         $this->xmlWriter->text($odataProperty->typeName);
     }
     if ($isTopLevel) {
         $this->xmlWriter->startAttribute(ODataConstants::XMLNS_NAMESPACE_PREFIX);
         $this->xmlWriter->text(ODataConstants::ODATA_METADATA_NAMESPACE);
         $this->xmlWriter->startAttributeNs(ODataConstants::XMLNS_NAMESPACE_PREFIX, ODataConstants::ODATA_NAMESPACE_PREFIX, null);
         $this->xmlWriter->text(ODataConstants::ODATA_NAMESPACE);
         $this->xmlWriter->startAttributeNs(ODataConstants::XMLNS_NAMESPACE_PREFIX, ODataConstants::ODATA_METADATA_NAMESPACE_PREFIX, null);
         $this->xmlWriter->text(ODataConstants::ODATA_METADATA_NAMESPACE);
     }
     if ($odataProperty->typeName != null || $isTopLevel) {
         $this->xmlWriter->endAttribute();
     }
 }
开发者ID:maxromanov,项目名称:odataphpprod,代码行数:27,代码来源:AtomODataWriter.php

示例3: array_to_xml

 /**
  * Convert array into XML by recursively generating child elements
  *
  * First instantiate a new XML writer object:
  *
  * $xml = new XMLWriter();
  *
  * Open in memory (alternatively you can use a local URI for file output)
  *
  * $xml->openMemory();
  *
  * Then start the document
  *
  * $xml->startDocument( '1.0', 'UTF-8' );
  *
  * Don't forget to end the document and output the memory
  *
  * $xml->endDocument();
  *
  * $your_xml_string = $xml->outputMemory();
  *
  * @since 2.2.0
  * @param \XMLWriter $xml_writer XML writer instance
  * @param string|array $element_key name for element, e.g. <per_page>
  * @param string|array $element_value value for element, e.g. 100
  * @return string generated XML
  */
 public static function array_to_xml($xml_writer, $element_key, $element_value = array())
 {
     if (is_array($element_value)) {
         // handle attributes
         if ('@attributes' === $element_key) {
             foreach ($element_value as $attribute_key => $attribute_value) {
                 $xml_writer->startAttribute($attribute_key);
                 $xml_writer->text($attribute_value);
                 $xml_writer->endAttribute();
             }
             return;
         }
         // handle multi-elements (e.g. multiple <Order> elements)
         if (is_numeric(key($element_value))) {
             // recursively generate child elements
             foreach ($element_value as $child_element_key => $child_element_value) {
                 $xml_writer->startElement($element_key);
                 foreach ($child_element_value as $sibling_element_key => $sibling_element_value) {
                     self::array_to_xml($xml_writer, $sibling_element_key, $sibling_element_value);
                 }
                 $xml_writer->endElement();
             }
         } else {
             // start root element
             $xml_writer->startElement($element_key);
             // recursively generate child elements
             foreach ($element_value as $child_element_key => $child_element_value) {
                 self::array_to_xml($xml_writer, $child_element_key, $child_element_value);
             }
             // end root element
             $xml_writer->endElement();
         }
     } else {
         // handle single elements
         if ('@value' == $element_key) {
             $xml_writer->text($element_value);
         } else {
             // wrap element in CDATA tags if it contains illegal characters
             if (false !== strpos($element_value, '<') || false !== strpos($element_value, '>')) {
                 $xml_writer->startElement($element_key);
                 $xml_writer->writeCdata($element_value);
                 $xml_writer->endElement();
             } else {
                 $xml_writer->writeElement($element_key, $element_value);
             }
         }
         return;
     }
 }
开发者ID:javolero,项目名称:dabba,代码行数:76,代码来源:class-sv-wc-helper.php

示例4: createPageMetadata

 private function createPageMetadata($strPageId, XMLWriter $objWriter)
 {
     //loop all languages if given
     $objLanguages = new class_module_languages_language();
     $strCurrentLanguage = $objLanguages->getStrAdminLanguageToWorkOn();
     $arrLanguages = class_module_languages_language::getObjectList();
     foreach ($arrLanguages as $objOneLanguage) {
         $objLanguages->setStrAdminLanguageToWorkOn($objOneLanguage->getStrName());
         $objPage = new class_module_pages_page($strPageId);
         $objWriter->startElement("propertyset");
         $objWriter->startAttribute("language");
         $objWriter->text($objOneLanguage->getStrName());
         $objWriter->endAttribute();
         $objWriter->startElement("browsername");
         $objWriter->text($objPage->getStrBrowsername());
         $objWriter->endElement();
         $objWriter->startElement("description");
         $objWriter->text($objPage->getStrDesc());
         $objWriter->endElement();
         $objWriter->startElement("keywords");
         $objWriter->text($objPage->getStrKeywords());
         $objWriter->endElement();
         $objWriter->startElement("template");
         $objWriter->text($objPage->getStrTemplate());
         $objWriter->endElement();
         $objWriter->startElement("seostring");
         $objWriter->text($objPage->getStrSeostring());
         $objWriter->endElement();
         $objWriter->startElement("language");
         $objWriter->text($objPage->getStrLanguage());
         $objWriter->endElement();
         $objWriter->startElement("alias");
         $objWriter->text($objPage->getStrAlias());
         $objWriter->endElement();
         $objWriter->startElement("path");
         $objWriter->text($objPage->getStrPath());
         $objWriter->endElement();
         $objWriter->startElement("target");
         $objWriter->text($objPage->getStrTarget());
         $objWriter->endElement();
         //propertyset
         $objWriter->endElement();
     }
     $objLanguages->setStrAdminLanguageToWorkOn($strCurrentLanguage);
 }
开发者ID:jinshana,项目名称:kajonacms,代码行数:45,代码来源:class_systemtask_pageexport.php

示例5: startAttribute

 /**
  * Start attribute
  *
  * @param string $name
  * @param string $value
  */
 public function startAttribute($name, $value)
 {
     $this->checkStartAttribute($name);
     $this->xmlWriter->startAttribute($name);
     $this->xmlWriter->text($value);
 }
开发者ID:dfritschy,项目名称:ezpublish-kernel,代码行数:12,代码来源:Xml.php

示例6: function

<?php

/* Codeine
 * @author bergstein@trickyplan.com
 * @description: Simple HTML Renderer
 * @package Codeine
 * @version 8.x
 */
setFn('Render', function ($Call) {
    $Call = F::Hook('beforeRSSPipeline', $Call);
    $XML = new XMLWriter();
    $XML->openMemory();
    $XML->startDocument('1.0', 'UTF-8');
    $XML->setIndent(true);
    $XML->startElement('rss');
    $XML->startAttribute('version');
    $XML->text('2.0');
    $XML->endAttribute();
    $XML->startElement('channel');
    $XML->writeElement('title', $Call['Project']['Title']);
    // FIXME
    $XML->writeElement('link', $Call['HTTP']['Proto'] . $Call['HTTP']['Host'] . $Call['Link']);
    if (isset($Call['Page']['Description'])) {
        $XML->writeElement('description', $Call['Page']['Description']);
    } else {
        $XML->writeElement('description', '');
    }
    $XML->writeElement('generator', 'Codeine ' . $Call['Version']['Codeine']['Major']);
    $XML->writeElement('pubDate', date(DATE_RSS, time()));
    $XML->writeElement('lastBuildDate', date(DATE_RSS, time()));
    if (!isset($Call['Slug'])) {
开发者ID:trickyplan,项目名称:codeine,代码行数:31,代码来源:RSS.php

示例7: save

 /**
  * Saves the result document.
  *
  * @return string
  * @throws \PhpOffice\PhpWord\Exception\Exception
  */
 public function save()
 {
     foreach ($this->temporaryDocumentHeaders as $index => $headerXML) {
         $this->zipClass->addFromString($this->getHeaderName($index), $this->temporaryDocumentHeaders[$index]);
     }
     $this->zipClass->addFromString('word/document.xml', $this->temporaryDocumentMainPart);
     $word = new Word2007();
     $read = $word->readRelationships($this->zipClass->filename);
     if (count($this->imageData)) {
         $read['document'] = array_merge($read['document'], $this->imageData);
         $xml = new \XMLWriter();
         $xml->openMemory();
         $xml->setIndent(true);
         $xml->startDocument('1.0', 'UTF-8');
         $xml->startElement('Relationships');
         $xml->startAttribute('xmlns');
         $xml->text('http://schemas.openxmlformats.org/package/2006/relationships');
         $xml->endAttribute();
         foreach ($read['document'] as $key => $data) {
             $xml->startElement('Relationship');
             $xml->startAttribute('Id');
             $xml->text($key);
             $xml->endAttribute();
             $xml->startAttribute('Type');
             $xml->text('http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $data['type']);
             $xml->endAttribute();
             $xml->startAttribute('Target');
             $xml->text($data['type'] === 'image' ? $data['docPart'] : $data['docPart'] . '.xml');
             $xml->endAttribute();
             $xml->endElement();
         }
         $xml->endElement();
         $xml->endDocument();
         $this->zipClass->addFromString('word/_rels/document.xml.rels', $xml->outputMemory(true));
     }
     foreach ($this->temporaryDocumentFooters as $index => $headerXML) {
         $this->zipClass->addFromString($this->getFooterName($index), $this->temporaryDocumentFooters[$index]);
     }
     // Close zip file
     if (false === $this->zipClass->close()) {
         throw new Exception('Could not close zip file.');
     }
     return $this->temporaryDocumentFilename;
 }
开发者ID:OAFCROB,项目名称:PHPWord,代码行数:50,代码来源:TemplateProcessor.php

示例8: ExportToRss

 /**
  * Used to export the given data as rss feed
  *
  * It returns a xml data string containing rss feed data
  *
  * @link http://www.w3schools.com/xml/xml_syntax.asp
  * @param array $data the data to be exported to rss format
  * @param array $xml_namespace the xml namespace for the document
  *     prefix => string the xml namespace prefix
  *     name => string the xml namespace name
  *     uri => string the xml namespace uri
  * @param array $namespace_attributes the list of tags that need to be prefixed with namespace
  * 
  * @return string $rss_file the contents of the rss file
  */
 public function ExportToRss($data, $xml_namespace, $namespace_attributes)
 {
     /** The XMLWriter class object is created. The XMLWriter php extension is enabled by default */
     $writer = new \XMLWriter();
     $writer->openMemory();
     /** The xml prolog is added */
     $writer->startDocument('1.0', 'UTF-8');
     $writer->setIndent(true);
     $writer->startAttributeNS($xml_namespace['prefix'], $xml_namespace['name'], $xml_namespace['uri']);
     /** The rss tag is opened */
     $writer->startElement('rss');
     $writer->startAttribute('version');
     $writer->text('2.0');
     $writer->endAttribute();
     $writer->startElement('channel');
     /** Each Item is added to the rss feed */
     for ($count = 0; $count < count($data); $count++) {
         $data_item = $data[$count];
         $writer->startElement('item');
         /** Xml tag is created for each data item */
         foreach ($data_item as $tag_name => $tag_value) {
             /** If the tag name is in the list of tags that need to be prefixed with namespace */
             if (in_array($tag_name, $namespace_attributes)) {
                 /** The namespace is added to the tag name */
                 $tag_name = $xml_namespace['name'] . ":" . $tag_name;
             }
             $writer->startElement($tag_name);
             $writer->text($tag_value);
             $writer->endElement();
         }
         $writer->endElement();
     }
     $writer->endElement();
     $writer->endElement();
     $writer->endDocument();
     /** The xml data is exported to string */
     $rss_file = $writer->outputMemory(TRUE);
     return $rss_file;
 }
开发者ID:Negative-Network,项目名称:Pak-PHP,代码行数:54,代码来源:String.php

示例9: function

 * @version 8.x
 */
setFn('Run', function ($Call) {
    $XML = new XMLWriter();
    $XML->openMemory();
    $XML->startDocument('1.0', 'UTF-8');
    $XML->setIndent(true);
    $XML->startElement('methodCall');
    $XML->startElement('methodName');
    $XML->text($Call['Method']);
    $XML->endElement();
    $Root = '';
    $XML->startElement('params');
    F::Map($Call['Call'], function ($Key, $Value) use($XML, &$Root) {
        if (substr($Key, 0, 1) == '@') {
            $XML->startAttribute(substr($Key, 1));
            $XML->text($Value);
            $XML->endAttribute();
        } else {
            if (is_numeric($Key)) {
                if ($Key > 0) {
                    // FIXME Костыль!
                    $XML->endElement();
                }
            } else {
                $XML->startElement($Key);
                $Root = $Key;
            }
            if (is_array($Value)) {
            } else {
                $XML->text($Value);
开发者ID:trickyplan,项目名称:codeine,代码行数:31,代码来源:XML-RPC.php

示例10: count

    print "Connect failed: " . $mysqli->connect_error . "\n";
    exit;
}
/* set character set */
if (!$mysqli->set_charset("utf8")) {
    print "Error loading character set utf8: " . $mysqli->error;
    exit;
}
$sql = "\n\t\tSELECT\n\t\t\tl_make as vendor,\n\t\t\tl_model,\n\t\t\tl_geo_city as geo,\n\t\t\tcount(*) as num,\n\t\t\tsum(if(cmp_rank is null,0,1)) as promoted,\n\t\t\tif((sum(if(cmp_rank is null,0,1)) / count(*)) > 0.6,'true','false') as flag,\n\t\t\tl_subcategory as category,\n\t\t\tif(l_isdealer=1,'new','used') as `type`,\n\t\t\tconcat(\n\t\t\t\t'http://vehicles.pingola.ru/search/транспорт/',\n\t\t\t\tl_geo_city,\n\t\t\t\t'/?make=',\n\t\t\t\tl_make,\n\t\t\t\t'&model=',\n\t\t\t\tl_model,\n\t\t\t\tif(l_subcategory<>'','&bodytype=',''),\n\t\t\t\tl_subcategory,\n\t\t\t\tif(l_isdealer=1,'&type=Новые','&type=Подержанные')\n\t\t\t) as link\n\t\tFROM ru_eyezeek.vehicles v\n\t\t\tleft join ru_eyezeek.promoted_vehicles p on v.l_id=p.o_l_id\n\t\twhere l_isactive=1 and l_make<>'' and l_model<>'' and l_geo_city<>''\n\t\tgroup by l_make,l_model,l_geo_city,l_subcategory,l_isdealer\n\t\torder by num desc limit 10000";
if ($result = $mysqli->query($sql)) {
    $writer = new XMLWriter();
    $writer->openURI('/home/eyezeek/netup/ru/context_rk/context_rk.xml');
    $writer->startDocument('1.0', 'UTF-8');
    $writer->setIndent(TRUE);
    $writer->startElement('ROOT');
    $writer->writeElement('CreationDate', date("d/m/y : H:i:s", time()));
    while ($arr = $result->fetch_assoc()) {
        $writer->startElement('row');
        foreach ($arr as $name => $value) {
            $writer->startElement('field');
            $writer->startAttribute('name');
            $writer->text($name);
            $writer->endAttribute();
            $writer->text($value);
            $writer->endElement();
        }
        $writer->endElement();
    }
    $writer->endDocument();
    $writer->flush();
}
开发者ID:sergrin,项目名称:crawlers-il,代码行数:31,代码来源:context_rk.php

示例11: XMLWriter

<?php

/* $Id$ */
$xw = new XMLWriter();
$xw->openMemory();
$xw->startDocument('1.0', 'UTF-8');
$xw->startElement("tag1");
$res = $xw->startAttribute('attr1');
$xw->text("attr1_value");
$xw->endAttribute();
$res = $xw->startAttribute('attr2');
$xw->text("attr2_value");
$xw->endAttribute();
$xw->text("Test text for tag1");
$res = $xw->startElement('tag2');
if ($res < 1) {
    echo "StartElement context validation failed\n";
    exit;
}
$xw->endDocument();
// Force to write and empty the buffer
echo $xw->flush(true);
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:24,代码来源:OO_003.php

示例12: function

/* Codeine
 * @author bergstein@trickyplan.com
 * @description: Simple HTML Renderer
 * @package Codeine
 * @version 8.x
 */
setFn('Render', function ($Call) {
    $XML = new XMLWriter();
    $XML->openMemory();
    $XML->startDocument('1.0', 'UTF-8');
    $XML->setIndent(true);
    if (isset($Call['Output']['Root'])) {
        $XML->startElement($Call['Output']['Root']);
        if (isset($Call['Namespace'])) {
            $XML->startAttribute('xmlns');
            $XML->text($Call['Namespace']);
            $XML->endAttribute();
        }
        if (isset($Call['Attributes'])) {
            foreach ($Call['Attributes'] as $Key => $Value) {
                if (is_array($Value)) {
                    $XML->startAttributeNs($Value['Prefix'], $Value['Key'], null);
                    $XML->text($Value['Value']);
                } else {
                    $XML->startAttribute($Key);
                    $XML->text($Value);
                }
                $XML->endAttribute();
            }
        }
开发者ID:trickyplan,项目名称:codeine,代码行数:30,代码来源:XML.php


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